android - Json object multiple array Parse, retrofit -
i have json string. couldn't onresponse retrofit 2 list(categories , product). how call, callback? should use what? not normaly list, right?
{ "categories": [{"name":"x products", "products":[{}{}{}]} {"name":"y products", "products":[{}{}{}]} {"name":"z products", "products":[{}{}{}]} ], "coverpageurl":"xx.png", "location": "canada", "adress":"opposite of hospital" "productitems": [ {"large":"xx" "mall":"tt"} {"large":"yy" "mall":"gg"}] "status": { "errorcode": 0, "error": null, "haserror": false }
in
call<merchant> call = toolapi.getapi().getmerchant(baseservice.token); call.enqueue(new callback<merchant>() { @override public void onresponse(response<merchant> response, retrofit retrofit) { if (response.body() == null) { }else{ //i bought bottoms class example //normaly 1 list , its' items. in case have 2 list on json //start homepagecontent homepagecontent = response.body(); integer errorcode = homepagecontent.getstatus().geterrorcode(); if (errorcode == 0) { /// should write here list<itemhomepagecontent> items = homepagecontent.getitems(); headrecyclerlisthomepagecontent.sethasfixedsize(true); homepageadapter = new homepageadapter(homepagecontent, items, context()); headrecyclerlisthomepagecontent.setlayoutmanager(new linearlayoutmanager(context(), linearlayoutmanager.vertical, false)); headrecyclerlisthomepagecontent.setadapter(homepageadapter); //finish } @override public void onfailure(throwable t) { } ....
in block // should write here
should this: merchant merchant = response.body();
in merchant
class should fields getmerchant
returns.
btw json invalid.
Comments
Post a Comment