json parsing a repeating variable with gson
I'm t开发者_开发问答rying to parse json request using google GSON (on Android although this is generic pasring question). Having trouble with creating the correct object structure to match the following JSON object.
JSON object
"slideshow": [
{
"url": "http:\/\/www.myurl.com"
},
{
"url": "http:\/\/www.myurl2.com"
}]
Java Object
public static class Slideshow {
//@SerializedName("url")
private String[] slideUrl;
public String[] getSlideUrl() {
return slideUrl;
}
public void setSlideUrl(String[] slideUrl) {
this.slideUrl = slideUrl;
}
}
Getting Parse error:
com.google.gson.JsonParseException: Expecting object found: [{"url":"http://www.myurl.com"},{"url":"http://www.myurl2.com"}]
Try this
private List<String> slideUrl;
and also change the getter and setter.
Cheers Ron
精彩评论