[英]SBJsonParser isn't returning correctly, how do I deal with this data?
When I use the SBJsonParser I don't get an NSDictionary I can use. 当我使用SBJsonParser时,我没有可以使用的NSDictionary。 Here is the code I used on the JSON string returned by my request:
这是我在请求返回的JSON字符串上使用的代码:
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *stuff = [parser objectWithString:jsonString error:nil];
When I print out the dictionary it created I see: { conferences = ( ( "demo", "Demo Database" ), ( "dev", "Development Database" ), ( "TESTING", "Testing Database" ), ( T2011, "T 2011" ), ( "C2010", "C2010" ) ); 当我打印出它创建的字典时,我看到:{Conferences =((“ demo”,“ Demo Database”),(“ dev”,“ Development Database”),(“ TESTING”,“ Testing Database”),(T2011 ,“ T 2011”),(“ C2010”,“ C2010”)); }
}
and I've tried to access some of the data but I am unable to because it does not recognize any of the key's I use. 并且我尝试访问某些数据,但无法访问,因为它无法识别我使用的任何密钥。 How would I access the data in this Dictionary?
我将如何访问该词典中的数据? Or is this incorrect?
还是不正确?
Thank you! 谢谢!
The return type is either a NSDictionary or a NSArray depending on the structure of the JSON. 返回类型是NSDictionary或NSArray,具体取决于JSON的结构。 In your case the data is probably interpreted as an array of key value pairs which might be returned to you as a NSArray.
在您的情况下,数据可能被解释为键值对的数组,可能会以NSArray的形式返回给您。
Edit: (As seen in the comments below) the parsing result was returned as a NSDictionary with a NSArray for the key "conferences". 编辑:(如在下面的评论中看到的),解析结果作为NSDictionary返回,带有NSArray作为键“ conferences”。 The NSArray in turn didn't store key value pairs but other NSArrays with two elements each.
反过来,NSArray不存储键值对,而是存储每个都有两个元素的其他NSArray。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.