1

I am using JSONKit in an iPhone app to decode a JSON string passed back from a webservice. All is dandy, except I am having to do (what I think) is some extra processing on the returned dictionary to get to my core values. Note that I am a complete Objective C noob so I assume I am doing something wrong and am looking for some guidance.

The JSON string:

{"d":[{"UserId":"20", "UserName":"hereIsAName"}]}

Here is what I have to do just to get my values; the final masterItems2 dictionary has both items.

NSDictionary *masterItems = [jsonKitDecoder objectWithData:jsonData];
NSArray *items = [masterItems valueForKey:@"d"];
NSDictionary *masterItems2 = [items objectAtIndex:0];

So, it seems like I am having to do an extra hop, right? If my JSON return string wasn't properly wrapped in the "d", my first dictionary would have all my values. All the examples I have seen for JSONKit use JSON that isn't wrapped in the "d", which is of course there for security.

Thanks for any insight.

malenkiy_scot
  • 16,415
  • 6
  • 64
  • 87
JoeFrank99
  • 11
  • 2

0 Answers0