android - parsing json array which is returned as object using retrofit -


how can parse following response api using retrofit lib in android?

{   "elements": {     "12": {         ...     },     "23": {         ...     },     "32": {         ...     }   },    "more": null } 

here elements json object needed array.

here trying

public static class elementresponsedeserializer implements jsondeserializer<elementresponse>{         @override         public elementresponse deserialize(jsonelement json, type typeoft, jsondeserializationcontext context) throws jsonparseexception {             logger.d("json >>>> typeoft" + typeoft.tostring());             logger.d("json >>>> context" + context.tostring());             logger.d("json >>>> " + json.tostring());             jsonobject object = json.getasjsonobject();             object.get             return new elementresponse();         }     } 

and using way

gson gson = new gsonbuilder()            .registertypeadapter(elementsresponse.class, new elementsresponsedeserializer())                     .create();  restadapter restadapter = new restadapter.builder()        .setclient(new okclient(client))        .setendpoint(url_api)        .setconverter(new gsonconverter(gson))        .setrequestinterceptor(new apirequestinterceptor())        .build(); restadapter.setloglevel(restadapter.loglevel.full); return restadapter.create(myapp.class); 


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -