简体   繁体   English

SBJsonParser没有正确返回,如何处理此数据?

[英]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.

相关问题 SBJsonParser:如果我不保留返回值,应用程序将崩溃 - SBJsonParser: App crashes if I do not retain the return value 如何在未启用iCloud时存储核心数据日志? - How do I store core data logs when iCloud isn't enabled? 我如何处理异步意大利面条代码? - How do I deal with asynchronous spaghetti code? 我如何处理Flurries的积累? - How do I deal with an accumulation of Flurries? 如何在iOS中使用Swift正确检索加速度计数据? - How do I retrieve accelerometer data correctly with Swift in iOS? 如何显示不属于UINavigationController根目录的UITabBar? - How do I display a UITabBar that isn't part of the root of my UINavigationController? 如何正确处理App Store的频繁更新? - How to correctly deal with frequent updates to the App Store? 你如何处理在iOS中获取数据的单独线程? - How do you deal with separate threads fetching data in iOS? UIPageViewController,如何正确跳转到特定页面而不会弄乱数据源指定的顺序? - UIPageViewController, how do I correctly jump to a specific page without messing up the order specified by the data source? 适用于iO的Facebook SDK无法正常运行 - Facebook SDK for iOs isn't working correctly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM