开发者

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. Here is the code I used on the JSON string returned by my reque开发者_StackOverflow社区st:

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" ) ); }

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. In your case the data is probably interpreted as an array of key value pairs which might be returned to you as a NSArray.

Edit: (As seen in the comments below) the parsing result was returned as a NSDictionary with a NSArray for the key "conferences". The NSArray in turn didn't store key value pairs but other NSArrays with two elements each.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜