【发布时间】:2014-06-06 07:37:49
【问题描述】:
我有与此类似的 JSON 许多 id 和 ref 键:
jSon = {
"id":"node1",
"name":"Languages",
"rel":"",
"children":1,
"step":1,
"path":1,
"nodes":[
{
"id":"node2",
"name":"Java",
"rel":"Pure Object Oriented Prog",
"children":1,
"step":2,
"path":2,
"nodes":[
{
"id":"node3",
"name":"C#",
"rel":"Framework",
"children":0,
"step":3,
"path":3,
"nodes":[]
},{
"id":"node4",
"name":"C++",
"rel":"OOPS",
"children":0,
"step":3,
"path":4,
"nodes":[]
}]
}]
};
在 Objective-C 中,我如何到达元素的父节点,其中键为 id,值是 node4 或其他内容。
在 xcode 中,我试图解析来自 MVC web API 的 JSON 数据。
我的web.api JSON 是this
当我注释掉 Newtonsoft.Json.PreserveReferencesHandling.Objects 时,JSON 变得非常大,通常像 35MB。
当我使用 PreserveReferencesHandling.Objects 时,.net 会使用 id 和 ref 键来重复对象。
在 JSON 中旅行时,如果到达带有值 asdfg 的 ref 键,我必须使用键 id 和值 `asdf 搜索返回节点。
Xcode 可以这样做吗?
【问题讨论】:
标签: ios objective-c json asp.net-web-api