ios - reading a json object from a website in objective c -


i need separate sub person, name, age, home addr, office addr below given json object retrieved website

{ "person" :

[{"subperson":{"home":{"id":"kljljk"},"name":"person3","age":"18","addr":{"home addr":"ksdjr","office addr":"kjshdg"}}}]}

tried nsjsonserialization,sbjson , touchjson api's. returns dictionary in person key , else value(format of json string specified below code) code:

nsurlrequest *urlreq = [nsurlrequest requestwithurl:url]; nsdata *response = [nsurlconnection sendsynchronousrequest:urlreq returningresponse:nil error:nil]; [webviv loadrequest:urlreq]; sbjsonparser *jsonparser = [sbjsonparser new]; nsdictionary *json = [jsonparser objectwithdata:response]; nslog(@"%@\n", json); for(id key in json) {      nslog(@"%@=%@",key,[json objectwithkey: key]); }  //output person = (everythingelse starting [, can't separate name , other required things)  //using nsjsonserialization if ([nsjsonserialization jsonobjectwithdata:response options:0 error:&error])  {     nslog(@"json"); }  nsdata *ptl = [nsjsonserialization jsonobjectwithdata:response options:0 error:&error]; nslog(@"%@",ptl);  //output same //for(int i=0;i<[ptl count];i++) //{ //nslog(@"%d",i); //} //even loop output same 

tell backend guys(the person wrote web service) change "[" "(" , "]" as")". ( array { dictionary. [ nothing can differentiate it


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -