0

这是我的 JSON 响应:

{"#error":false,
 "#data":
    {"personal_info":
        {"basic_information":
            {"EmailAddress":"k_bhuvaneswari@hcl.com",
             "PasionProfessional":null,
             "PasionPersonal":null,
             "WorkLocation":"Chennai-AMB-6, Amb. Ind. Est., MTH Rd, 8",
             "Country":null,
             "City":null,
             "Latitude":null,
             "Longitude":null,
             "Title":"Software Engineer",
             "HomeTown":null,
             "RelationshipStatus":null,
             "BriefBio":null,
             "FavouriteQuotation":null},
         "education":
            {"HighSchool":null,
             "HighSchoolYear":null,
             "HigherSecondary":null,
             "HSSYear":null,
             "DiplomaTechnical":null,
             "DiplomaInsitute":null,
             "YearofDiploma: ":null,
             "Degree":null,
             "YearofPassing":null,
             "College/University":null,
             "PostGraduation":null,
             "YearofPostGraduation":null,
             "PGCollege/University":null},
         "interest":
            {"Keywords":null},
         "contact_information":
            {"MobilePhone":"9791729428",
             "BusinessCode":null,
             "BusinessPhone":null,
             "OtherCode":null,
             "OtherPhone":null,
             "Website":null}},
     "work_profile_info":
        {"profile_title":"",
         "profile_bio":""},
     "boolean":"1"}}

现在我想像这样以编程方式显示标签:

EmailAddress          k_bhuvaneswari@hcl.com
PasionProfessional    Nil

我怎样才能做到这一点?

4

1 回答 1

0

很容易。您需要一个 JSON 库来解析您收到的数据。我个人喜欢JSONKit

NSURL *url = [NSURL URLWithString:@"http://url.com"];
NSData *data = [NSData dataWithContentsOfURL:url];
NSDictionary *dict = [data objectFromJSONString]; //JSONKit

然后你可以放下结构并抓住你想要的东西:

NSString *email = [dict valueForKeyPath:@"#data.personal_info.basic_information. EmailAddress"];
于 2011-06-13T17:52:48.690 回答