Question

Hi, I got the string from facebook api as:

family = (
    {relationship = brother;uid = 100767;},
   relationship = cousin;uid = 10900;},
   {name = myaunt;relationship = aunt;},
   { name = krish; relationship = uncle;}
);

How to get an array of relationship and uid from this?

I got the result as:

relation = (
    brother,
    cousin,
    aunt,
    uncle
)

How to handle this string?

Était-ce utile?

La solution

There is no native code to parse a JSON response with objective-c, but there are third party libraries readily available. TouchJSON is a popular example of this.

Autres conseils

if you are using ios 5

NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData: self.responseData options: NSJSONReadingMutableContainers error: &err];

else use SBJSON from github parser to parse the repsonse of facebook api

NSArray *response = [[responseDictionary objectForKey:@"family"] valueForKey:@"relationship"];

and store them in array same can be achieved for UID also

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top