How do I parse JSON with Objective-C?

前端 未结 5 1641
暖寄归人
暖寄归人 2020-11-22 07:18

I am new to iPhone. Can anyone tell me the steps to follow to parse this data and get the activity details, first name, and last name?

{
    \"#error\": fals         


        
5条回答
  •  日久生厌
    2020-11-22 08:24

    Don't reinvent the wheel. Use json-framework or something similar.

    If you do decide to use json-framework, here's how you would parse a JSON string into an NSDictionary:

    SBJsonParser* parser = [[[SBJsonParser alloc] init] autorelease];
    // assuming jsonString is your JSON string...
    NSDictionary* myDict = [parser objectWithString:jsonString];
    
    // now you can grab data out of the dictionary using objectForKey or another dictionary method
    

提交回复
热议问题