FYI, if your JSON is an array: {"results:":[{"title":"aaa","url":"bbb","image":{"url":"ccc","width":"100","height":"20...},{}]}
Then you need a wrapper class:
class WebServiceResult { public List<AccessorClass> results; }
If your JSON is not formatted this way, then your For loop that you created will do it (if not a little clumsy, it would be better if your JSON is generated as above).
Create Image Class
class ImageClass { private String url; private int width; private int height;
Then change your AccessorClass
@SerializedName("image") private ImageClass image;
Then gson input line
Gson gson = new Gson(); AccessorClass object = gson.fromJson(result, AccessorClass.class);
The task is completed.
source share