How to know if object value is existing in JSON on android? -


hei i'm new web service using android. want know how check if value exist in json? here sample json

{    "contacts": [      {             "id": "c200",             "name": "michael jordan",             "email": "mj@gmail.com",             "address": "xx-xx-xxxx,x - street, x - country",             "gender" : "male",             "phone": {                 "mobile": "+91 0000000000",                 "home": "00 000000",                 "office": "00 000000"             }      }    ] } 

i want know if name michael jordan existing in json. please me know how check if object exist in json using has how if want check value?

you need read content jsonobject. can add code snippet

jsonarray jsonarray = yourjsonobject.getjsonarray("contacts"); //here yourjsonobject object has array in question. for(int = 0; i<jsonarray.length(); i++) {  jsonobject jobject = jsonarray.getjsonobject(i);  string name = jobject.getstring("name");  if(name.equals("michael jordan")) {  system.out.println("name exists");  } } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -