如何从 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"];
}
}
我曾希望找到可以执行此操作的方法或预定义函数 - 如果有,希望您将其添加为答案。
关于ios - 从 JSON API 中提取特定类型的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32324292/