2
它应该是如此简单,但我无法得到它的工作。 JSON响应为 ([{“id”:“1”,“x”:“1”,“y”:“2”},{“id”:2,“x”:“2” , “Y”: “4”}])iOS JSON解析成NSDictionary,然后用SBJson解析NSArray
NSString *response = [request responseString];
//response is ([{"id":"1", "x":"1", "y":"2"},{"id":2, "x":"2", "y":"4"}])
SBJSON *parser = [[[SBJSON alloc] init] autorelease];
NSDictionary *jsonObject = [parser objectWithString:response error:NULL];
// jsonObject doesn't have any value here..Am I doing something wrong?
NSMutableArray Conversion = [jsonObject valueForKey:NULL];
//Even if I get the value of jsonObject. I don't know what to put for valueForKey here
转换768,16有两个NSObjects..and它们中的每应具有像
ID:1 X:1 Y:2
和
id:2 x :2 y:4
尝试,并获得无效CFArrayRef为jsonObject..It似乎JSONObject的是没有得到任何东西。我用的断点检查,并能看到解析器得到了JSON值.. – MomentH 2012-04-23 22:23:27
我知道了..你的答案是完美的: )但Json返回我得到了(和)所以解析器无法处理它..我已经删除与响应= [响应stringByReplacingOccurrencesOfString:@“(”withString:@“”];和响应= [响应stringByReplacingOccurrencesOfString:@“)”withString :@ “”]; **然后它的工作完美..谢谢.. :)是否有一些简单的方法来删除'('和')'在同一时间? – MomentH 2012-04-23 22:43:45