解析json给出错误

时间:2012-02-03 10:56:25

标签: iphone json

我使用脸谱图API,借助于此,我得到用户好友列出我想要的内容。它是JSON格式。正如我之前所做的那样,我在项目中导入了json类,我使用了以下方法。但它引发了一个错误,我不明白我到底错过了什么。

我的代码:

-(void)getuserfriends
{
NSDictionary *dict = [[NSDictionary alloc]initWithObjectsAndKeys:@"name,last_name,first_name",@"fields", nil];   
FbGraphResponse *fb_graph_response =  [fbGraph doGraphGet:@"me/friends" withGetVars:dict];  
NSLog(@"getMeFriendsButtonPressed:  %@",fb_graph_response.htmlResponse);
//htmlresponse is string
NSMutableDictionary *newdict = [fb_graph_response.htmlResponse JSONValue];
}

错误: 接收类型NSString for instance message不会声明具有选择器'JSONValue'的方法

1 个答案:

答案 0 :(得分:0)

这是因为NSString没有JSONValue方法。您必须使用解析字符串的JSON API并返回NSDictionary。

执行此操作时:

fb_graph_response.htmlResponse;

返回NSString。你调用不存在的JSONValue。

相关问题