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?

Was it helpful?

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top