嗨,我有以下需要解析的 json,但是,我正在努力解析内部数组。我目前只打印每个内部数组,但我想打印每个标题并将标题添加到数组中。感谢您的任何帮助!
JSON
{"nodes":[{
    "node":{
        "nid":"1420857",
        "title":"Title 1",
        "votes":"182",
        "popular":"True",
        "teaser":"Teaser 1"
    }},
    {"node":{
        "nid":"1186152",
        "title":"Title 2",
        "votes":"140",
        "popular":"True",
        "teaser":"Teaser 2"
    }},
    {"node":{
        "nid":"299856",
        "title":"Title 3",
        "votes":"136",
        "popular":"True",
        "teaser":"Teaser 3"
    }}
]}
Json 解析器
    NSError *error = nil;
    NSData *jsonData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.somefilename.json"]];
    if (jsonData) {
        id jsonObjects = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
        if (error) {
            NSLog(@"error is %@", [error localizedDescription]);
            return;
        }
        NSArray *keys = [jsonObjects allKeys];
        for (NSString *key in keys) {
            NSLog(@"%@", [jsonObjects objectForKey:key]);
        }
    } else {
        // Handle Error
    }