java - Parsing json using jackson and not able to reach and retrieve values from pojos -


i new jackson , trying retrieve values json response. json response : -

{ total: "1", count: "1", params: { res: "all", detail: "summary", smartcardid: "s1234567890", receiverid: "r1234567890", format: "all", lang: "en", storefronttype: "en", tcsmasterid: "41s7v" }, baseurl: { asset: "http://10.84.90.186/content/video/", poster: "http://10.84.90.186/content" }, items: [ { contenttype: "asset", endpointurl: "/assets/41s7v", showtype: "movie", tcsmasterid: "41s7v", title: "300: rise of empire", titlebrief: "300: rise of empire", summaryshort: "l ", summarymedium: "l ", summarylong: "l ", year: "2014", rating: "g", runtime: "00:14:59", displayruntime: "14", suggestedprice: "5.99", providerid: "www.mongrelmedia.com", maximumviewinglength: "2880", audiotype: [ "dolby digital 5.1" ], licensingwindowstart: "2015-01-01t00:00:00", licensingwindowend: "2015-12-31t12:00:00", genres: [ "movies/action , adventure" ], actors: [ " d" ], actorsdisplay: "d", reviewrating: { type: "rotten_tomatoes", criticsummarycount: "55", criticsummaryvalue: "71", criticsummaryrating: "3.0", fansummarycount: "47103", fansummaryvalue: "88", fansummaryrating: "4.0", fansummaryprerelease: false, reviews: [ { reviewid: "1727471", publicationid: "0", publication: "newsweek", date: "2008-05-12", freshnessscore: "null", freshness: "rotten", criticid: "0", criticname: "david ansen", quote: "for ambition, movie ends using great        historical events in service of dubious sentimentality." }, { reviewid: "1710100", publicationid: "0", publication: "film4", date: "2008-02-20", freshnessscore: "4/5", freshness: "fresh", criticid: "0", quote: "unashamedly sentimental, technically triumphant        tear-jerker." } ] }, rightsicondisplay: "ipt=1,dth=0,web=0,nsc=1,mob=0", wishlist: false, preview: { assetid: "41s8v21", type: "preview", contentpath: "www.mongrelmedia.com/41s8v21_a4289887-5f7c-47a4-afad-842c934025e1/mpl_41s8v21_a4289887-5f7c-47a4-afad-842c934025e1.m3u8", masterplaylist: "mpl_41s8v21_a4289887-5f7c-47a4-afad-842c934025e1.m3u8", runtime: "00:14:59" } } ] } 

i trying retrieve values : - items: [] such displayruntime: "14", , genre not able reach -

here main pojo class : -

 public class assetgen{         private baseurl baseurl;         private string count;         private list items;         private params params;         private string total;          public baseurl getbaseurl(){             return this.baseurl;         }         public void setbaseurl(baseurl baseurl){             this.baseurl = baseurl;         }         public string getcount(){             return this.count;         }         public void setcount(string count){             this.count = count;         }         public list getitems(){             return this.items;         }         public void setitems(list items){             this.items = items;         }         public params getparams(){             return this.params;         }         public void setparams(params params){             this.params = params;         }         public string gettotal(){             return this.total;         }         public void settotal(string total){             this.total = total;         }     } 

here item pojo :-

public class items{     private list actors;     private string actorsdisplay;     private list audiotype;     private string contenttype;     private string displayruntime;     private string endpointurl;     private list genres;     private string licensingwindowend;     private string licensingwindowstart;     private string maximumviewinglength;     private preview preview;     private string providerid;     private string rating;     private reviewrating reviewrating;     private string rightsicondisplay;     private string runtime;     private string showtype;     private string suggestedprice;     private string summarylong;     private string summarymedium;     private string summaryshort;     private string tcsmasterid;     private string title;     private string titlebrief;     private boolean wishlist;     private string year;      public list getactors(){         return this.actors;     }     public void setactors(list actors){         this.actors = actors;     }     public string getactorsdisplay(){         return this.actorsdisplay;     }     public void setactorsdisplay(string actorsdisplay){         this.actorsdisplay = actorsdisplay;     }     public list getaudiotype(){         return this.audiotype;     }     public void setaudiotype(list audiotype){         this.audiotype = audiotype;     }     public string getcontenttype(){         return this.contenttype;     }     public void setcontenttype(string contenttype){         this.contenttype = contenttype;     }     public string getdisplayruntime(){         return this.displayruntime;     }     public void setdisplayruntime(string displayruntime){         this.displayruntime = displayruntime;     }     public string getendpointurl(){         return this.endpointurl;     }     public void setendpointurl(string endpointurl){         this.endpointurl = endpointurl;     }     public list getgenres(){         return this.genres;     }     public void setgenres(list genres){         this.genres = genres;     }     public string getlicensingwindowend(){         return this.licensingwindowend;     }     public void setlicensingwindowend(string licensingwindowend){         this.licensingwindowend = licensingwindowend;     }     public string getlicensingwindowstart(){         return this.licensingwindowstart;     }     public void setlicensingwindowstart(string licensingwindowstart){         this.licensingwindowstart = licensingwindowstart;     }     public string getmaximumviewinglength(){         return this.maximumviewinglength;     }     public void setmaximumviewinglength(string maximumviewinglength){         this.maximumviewinglength = maximumviewinglength;     }     public preview getpreview(){         return this.preview;     }     public void setpreview(preview preview){         this.preview = preview;     }     public string getproviderid(){         return this.providerid;     }     public void setproviderid(string providerid){         this.providerid = providerid;     }     public string getrating(){         return this.rating;     }     public void setrating(string rating){         this.rating = rating;     }     public reviewrating getreviewrating(){         return this.reviewrating;     }     public void setreviewrating(reviewrating reviewrating){         this.reviewrating = reviewrating;     }     public string getrightsicondisplay(){         return this.rightsicondisplay;     }     public void setrightsicondisplay(string rightsicondisplay){         this.rightsicondisplay = rightsicondisplay;     }     public string getruntime(){         return this.runtime;     }     public void setruntime(string runtime){         this.runtime = runtime;     }     public string getshowtype(){         return this.showtype;     }     public void setshowtype(string showtype){         this.showtype = showtype;     }     public string getsuggestedprice(){         return this.suggestedprice;     }     public void setsuggestedprice(string suggestedprice){         this.suggestedprice = suggestedprice;     }     public string getsummarylong(){         return this.summarylong;     }     public void setsummarylong(string summarylong){         this.summarylong = summarylong;     }     public string getsummarymedium(){         return this.summarymedium;     }     public void setsummarymedium(string summarymedium){         this.summarymedium = summarymedium;     }     public string getsummaryshort(){         return this.summaryshort;     }     public void setsummaryshort(string summaryshort){         this.summaryshort = summaryshort;     }     public string gettcsmasterid(){         return this.tcsmasterid;     }     public void settcsmasterid(string tcsmasterid){         this.tcsmasterid = tcsmasterid;     }     public string gettitle(){         return this.title;     }     public void settitle(string title){         this.title = title;     }     public string gettitlebrief(){         return this.titlebrief;     }     public void settitlebrief(string titlebrief){         this.titlebrief = titlebrief;     }     public boolean getwishlist(){         return this.wishlist;     }     public void setwishlist(boolean wishlist){         this.wishlist = wishlist;     }     public string getyear(){         return this.year;     }     public void setyear(string year){         this.year = year;     } } 

here jackson code trying use : -

@suppresswarnings("rawtypes")     public string[] getshownwdetailsgopherparser (string url) throws jsonparseexception, jsonmappingexception, ioexception{          system.err.println("stage 1");         url jsonurl = new url(url);         objectmapper objmapper = new objectmapper();         objmapper.configure(deserializationfeature.fail_on_unknown_properties, false);         list<assetgen> jsongenshow_1 = objmapper.readvalue(jsonurl, new typereference <list<assetgen>>() {});         list [] shows = new list [jsongenshow_1.size()];          string[] showsarr = new string[jsongenshow_1.size()];         int = 0;         for(assetgen element : jsongenshow_1){             shows[i]=element.getitems().             showsarr[i]=shows[i].tostring();             i++;         }         return showsarr;         } 

need clear solution , new jackson.

items array. think more clear if rename pojo items item.

so value in single item should that:

 for(assetgen element : jsongenshow_1){         list<item> items=element.getitems();         (item item:items) {             //get item value            item.getruntime();            ....         }      } 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -