iphone - how to check key available or not in json response in ios -


after request server , recieve 2 different type of response

if success response this

[{"id":5,"is_default":0,"name":"dutch","language_id":3},{"id":4,"is_default":1,"name":"french","language_id":2}] 

other response type

 {"status":102,"response":"empty record list."} 

is way detect whether "status" key available or not in response in objc. thanks

found solution

   //break result tag     if([[responsestring jsonvalue] iskindofclass:[nsdictionary class]]){      nsdictionary *dict = [responsestring jsonfragmentvalue];      if([dict count]==2){       return;     }     //nothing load  } 

the response dictionary, see if have key looking can use nsdictionary methods:

// assume have created dictionary, jsonresponse, json  // first, keys in response  nsarray *responsekeys = [jsonresponse allkeys];  // see if array contains key looking  bool iserrorresponse = [responsekeys containsobject:@"status"]; 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -