I am using volley in my app for network requests.I am trying to use GSON library for JSON parsing and create a list view with that.JSON looks like this.When I try to run the code I got an exception. What is wrong with this and what is missing
[
{
"articles": {
"code": "/par/feed_sub_section",
"name": "News",
"title": "News",
"count": "25",
"page": "1",
"totalPages": "11",
"expiryTime": 100
},
"article": [
{
"title": "title 1",
"articleUrl": "articleUrl 1",
"thumbnail": "thumbnail 1",
"imgWeb": "imgWeb 1",
"imgMob": "imgMob 1",
"lastModified": "lastModified1",
"otherImages": "0",
"video": "false"
},
{
"title": "title2",
"articleUrl": "articleUrl2",
"thumbnail": "thumbnail2",
"imgWeb": "imgWeb2",
"imgMob": "imgMob2",
"lastModified": "lastModified2",
"otherImages": "0",
"video": "false"
},
{
"title": "title3",
"articleUrl": "articleUrl3",
"thumbnail": "thumbnail3",
"imgWeb": "imgWeb3",
"imgMob": "imgMob3",
"lastModified": "lastModified3",
"otherImages": "0",
"video": "false"
},
{
"title": "title4",
"articleUrl": "articleUrl4",
"thumbnail": "thumbnail4",
"imgWeb": "imgWeb4",
"imgMob": "imgMob4",
"lastModified": "lastModified4",
"otherImages": "0",
"video": "false"
}
]
}]
and my classes is like
public class Article {
String title;
String articleUrl;
String thumbnail;
String imgWeb;
String imgMob;
String lastModified;
String otherImages;
String video;}
public class Articles {
String code;
String name;
String title;
String count;
String page;
public class ArticleMainObject {
public Articles articles;
public List<Article> articleList;}
I use volley and try to parse result like this
GsonRequest<ArticleMainObject> myReq = new GsonRequest<ArticleMainObject >(Method.GET,
"http://JSONURL/",
ArticleMainObject .class,
createMyReqSuccessListener(),
createMyReqErrorListener());
When i run this code i got exception like this
com.android.volley.ParseError: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 4 column 2
I am stuck at this point.How to iterate through the result.I am new to GSON.So please help me