How to deserialize a JSON String that contains lists of objects within other objects? I found explanations for simple deserialization, but I can't extrapolate much from them, as they're all a little bit off. As an example(POJOs ommited), for
String json = "[ {
"id" : 33147,
"name" : "Refinancing",
"photos" : [ {
"name" : "347.png",
"url" : "/loans/568/photos/092"
} ],
"username" : "zach1985"
} , {
"id" : 7693,
"name" : "Stuff",
"photos" : [ {
"name" : "newpic1.png",
"url" : "/loans/123446/photos/890"
} ],
"username" : "sengaia"
} ]";
ArrayList<Ad> ads = new ArrayList<>;
deserialize(json, ads);
System.out.println(ads.get(1).getName());
System.out.println(ads.get(0).getPhotos().get(0).getName());
The outputs would be "Stuff" and "347". How would then the deserialize() method need to be implemented?