从 JSON API 中提取特定类型的属性

extract an attribute of a specific type from JSON API

如何从 JSON API 格式字符串中提取特定类型的属性?我使用 NSJSONSerialization- 但提取属性并将其放在 included.attributes

..."included":[{"id":"","type":"name1","attributes":{...}},{"id":"","type":"form-data","attributes":{..}}]}

序列化为:

included =     (
            {
        attributes =             {..};id = "";
        type = "name1";
    },
            {
        attributes =             {...};
        id = "";
        type = "name2";
    }
);
}

有没有一种方法可以根据类型的值提取属性值?

我使用以下代码提取了我需要的内容:

    for (NSMutableArray* oneRow in attributes) {
    if([[oneRow valueForKey:@"type"] isEqualToString:@"name"]){
        formAttribute = [oneRow valueForKey:@"attributes"];
    }
}

我曾希望找到可以做到这一点的方法或预定义函数-如果有,希望您将其添加为答案。