android - Using Jackson Json to parse Google Blogs post -


i have been struggling parse feed using jackson json parser.

here feed:

    { "responsedata": { "query": "official google blogs", "entries": [ { "url": "http://googleblog.blogspot.com/feeds/posts/default", "title": "<b>official blog</b>", "contentsnippet": "5 days ago <b>...</b> <b>official</b> weblog, news of new products, events , glimpses of life inside <br>  <b>google</b>.", "link": "http://googleblog.blogspot.com/" }, { "url": "http://googlewebmastercentral.blogspot.com/feeds/posts/default", "title": "<b>official google</b> webmaster central <b>blog</b>", "contentsnippet": "jul 12, 2013 <b>...</b> <b>official</b> weblog on <b>google</b> crawling , indexing, , on webmaster tools, <br>  including sitemaps facility.", "link": "http://googlewebmastercentral.blogspot.com/" },  { "url": "http://googlemac.blogspot.com/feeds/posts/default", "title": "<b>official google</b> mac <b>blog</b>", "contentsnippet": "jun 22, 2012 <b>...</b> <b>official</b> weblog <b>google</b> in apple macintosh world.", "link": "http://googlemac.blogspot.com/" } ] }, "responsedetails": null, "responsestatus": 200 } 

i have managed objects except "entries" array de-serialized.

any idea?

here code data model:

public class usermodel {  public static final string tag = usermodel.class.getsimplename()   public static class responsedata{     private string _query;     public string getquery(){return _query;}     public void setquery(string query){_query=query;}     // unable entries parsing   }    private string responsestatus; private string responsedetails;  private responsedata responsedata;   public responsedata getresponsedata() {     return responsedata; }    public void setresponsedata(responsedata responsedata) {        this.responsedata = responsedata;    }       public string getresponsestatus() {         return responsestatus;     }      public void setresponsestatus(string responsestatus) {         this.responsestatus = responsestatus;     }     public string getresponsedetails() {         return responsedetails;     }      public void setresponsedetails(string responsedetails) {         this.responsedetails = responsedetails;     }       @override     public string tostring() {         stringbuilder builder = new stringbuilder();         builder.append("responsestatus [responsestatus=");         builder.append(responsestatus);         builder.append(responsedata._query);         builder.append("]");         return builder.tostring();     }  } 

you need add list of entries list type responsedata class , create class represents entry class (called entry in below example, call whatever want).

public static class responsedata{       public list<entry> entries;      private string _query;      public string getquery(){return _query;}      public void setquery(string query){_query=query;}      // unable entries parsing   } 

edit: - make sure entry class contains properties json response. should have url, title, contentsnippet, , link property.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -