嗨,我从facebook api获得了字符串:
family = (
{relationship = brother;uid = 100767;},
relationship = cousin;uid = 10900;},
{name = myaunt;relationship = aunt;},
{ name = krish; relationship = uncle;}
);
如何从中获取一系列关系和uid?
我的结果是:
relation = (
brother,
cousin,
aunt,
uncle
)
如何处理这个字符串?
答案 0 :(得分:1)
没有使用objective-c解析JSON响应的本机代码,但是有第三方库可供使用。 TouchJSON就是一个很受欢迎的例子。
答案 1 :(得分:0)
如果您使用的是ios 5
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData: self.responseData options: NSJSONReadingMutableContainers error: &err];
否则使用github解析器中的SBJSON来解析facebook api的repsonse
NSArray *response = [[responseDictionary objectForKey:@"family"] valueForKey:@"relationship"];
并将它们存储在数组中同样可以实现UID