android - How to get key values from json object in retrofit 2.3 -




i trying parse json object dynamic keys , values , set them recyclerview in application. , want key or value when user clicks recyclerview child.

{ "status": 200, "message_type": "info",     "car_types": {         "sports_car": "bmw",          "sports_car": "lamborghini",         "classic_car": "benz",         "luxary_car": "bently cooper",         "suv": "range rover",         "other": "other"     } } 

try following,to key , value jsonobject.

   try {                  jsonobject jsonobject = new jsonobject("your result");                  jsonobject jsonobject1_message = jsonobject.getjsonobject("message_type");                  map<string,string> map = new hashmap<string,string>();                 iterator iter = jsonobject1_message.keys();                  while(iter.hasnext()){                     string key = (string)iter.next();                     string value = jsonobject1_message.getstring(key);                     map.put(key,value);                      log.d("keywithvalues","print    "+key+"   "+value);                  }                }catch (exception e)             {                         log.d("error","**   "+e.tostring());             } 

i hope may you.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -