Reputation: 113
I've been following this tutorial. I was trying to apply it to my case. The JSON feed I'll be using is: JSON feed.
They are using the following 'query':
json[@"loans"][0][@"name"]
So I tried it for my case using:
json[@"0"][@"format"]
or
json[@"0"][0][@"format"]
but both are returning null.
What am I doing wrong here?
Upvotes: 0
Views: 49
Reputation:
Well, because what you have is not JSON. (I. e., it's "invalid" JSON - for example, it doesn't have dictionary keys surrounded by quotation marks, so the JSON parser, whatever you use, will presumably return nil
because it can't parse it.)
By the way, even if it was valid JSON, neither of your approaches would have worked anyway. First you have an array as the root element, then its items are dictionaries. I. e., how you have to index is
json[0][@"format"]
(provided that json
is an already parsed object, and not the JSON string itself!)
Upvotes: 1