How to convert JSON array to java object -


this json i'm sending via post request

{   "pids" : [ "mob123", "elec456"] } 

this class receives json,

@post @consumes(mediatype.application_json) @produces(mediatype.application_json) @path("/getproductsinfo") public list<productdetails> getproductsinfo(productids productids) {      system.out.println(productids + "   ");      dbcursor<productdetails> dbcursor = collection.find(dbquery.in("pid", productids.getpids()));      list<productdetails> products = new arraylist<>();     while (dbcursor.hasnext()) {         productdetails product = dbcursor.next();         products.add(product);     }     return products; } 

im converting json array 'productids' object, pojo class

public class productids {     @jsonproperty("pids")     private list<string> pids;      public list<string> getpids()     {         return pids;     }      public void setpids(list<string> pids)     {         this.pids = pids;     }      @override     public string tostring()     {         return "classpojo [pids = "+ pids +"]";     } } 

the problem me here json not getting populated java object 'productids' null, dont know why. im new jackson can me out. thank you

did try id's out using .getjsonarray()? uses org.json library.

jsonobject obj = new jsonobject(jsoninput);  jsonarray jsonarray = obj.getjsonarray("pids"); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -