解析Json以获取一个NSArray中的所有内容 [英] Parsing Json to get all the contents in one NSArray
本文介绍了解析Json以获取一个NSArray中的所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这就是内容......
That's the content...
[
{
"id": "",
"title": "",
"website": "",
"categories": [
{
"id": "",
"label": ""
}
],
"updated":
},
{
"id": "",
"title": "",
"website": "",
"categories": [
{
"id": "",
"label": ""
}
],
"updated":
}
]
如何在一个数组中插入每个Feed源?
How can I insert every feed source in one array?
NSDictionary *results = [string JSONValue];
NSArray *subs = [results valueForKey:@"KEY"];
我必须插入哪个密钥?
谢谢
Which key I must insert? THanks
推荐答案
因为我可以看到你的结构,你将摆脱这个JSON-String
as I can see your structure, you will get out of this JSON-String
NSArray:
[
NSDictionary:
{
NSString: "id",
NSString: "title",
NSString: "website",
NSArray: "categories":
[
NSDictionary:
{
NSString: "id",
NSString: "label"
}
],
NSNumber: "updated"
},
NSDictionary:
{
...
}
]
所以你已经根目录中的Feeds数组,你必须使用它们中的索引来对它们进行迭代。对于第一个id,即 [[myJsonStructure objectAtIndex:0] objectForKey:@id];
So you have already an array of "Feeds" at root and you have to itterate them with their index in the array with. For first id i.e. [[myJsonStructure objectAtIndex:0] objectForKey:@"id"];
这篇关于解析Json以获取一个NSArray中的所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文