java - Retrofit parsing JSON response null values Android -
hi cant work out why getting null values response. im using retrofit library on android.
raw json
{ "images": [ { "image": { "name": "nike adver", "url": "http:\/\/wallpaperbarcelona.com\/wp-content\/uploads\/2013\/07\/neymar-nike-advert.jpg", "type": "photo" } }] } // interface
public interface promoimagesapi { @get("/friendscms/images/?type=photo&format=json") void promoimages(callback<imagesobject> callback); }
request function
private void requestnewsdata(string uri) { restadapter api = new restadapter.builder().setendpoint(endpoint).build(); promoimagesapi restapi = api.create(promoimagesapi.class); restapi.promoimages(new callback<images>() { @override public void success(images imageobjects, response response) { system.out.println("webservice " +response.geturl()); (int = 0; < imageobjects.images.size(); i++) { system.out.println("webservice " +imageobjects.getimages().get(i).geturl()); } } @override public void failure(retrofiterror error) { system.out.println("webservice " + error); } }); } pojo
public class imagesobject { public list<images> images; public class images { public string name; public string url; public string type; public string getname() { return name; } public string geturl() { return url; } public string gettype() { return type; } public void setname(string name) { this.name = name; } public void seturl(string url) { this.url = url; } public void settype(string type) { this.type = type; } } }
the thing amount of elements in loop correct, have tested that, values null. have missed something, gratefully appreciated .
use http://www.jsonschema2pojo.org/ create java object model , following call
public interface promoimagesapi { @get("/friendscms/images/?type=photo&format=json") void promoimages(callback<images> callback);
Comments
Post a Comment