Gere Tan
Gere Tan

Reputation: 43

enabling iPhone to fetch and parse JSON?

I don't know how to use the output=json;callback= for my iPhone App, appreciate for your help!

This URL at tw.money.yahoo.com returns this JSON:

{"ResultSet":{"totalResultsAvailable":"0",
              "Error":{"Code":400,
                       "Message":"\u67e5\u8a62\u53c3\u6578\u4e0d\u5408\u6cd5"}
             }
} 

Upvotes: 1

Views: 308

Answers (2)

Rams
Rams

Reputation: 1751

jsonkit

NSDictionary *listings = [[content objectFromJSONString] valueForKey:@"ResultSet"];

Upvotes: 0

deanWombourne
deanWombourne

Reputation: 38475

If you get the response as a string, then it's very simple to parse - it just gets turned into NSDictionary and NSArray objects :)

Get the touch-json framework from github.

NSString *myJsonString = @"{'name':'Bob'}";
NSDictionary *dict = [myJsonString JSONValue];

After calling JSONValue on a string, dict will contain the key "name" that has the value "Bob".

Upvotes: 3

Related Questions