【发布时间】:2012-10-05 14:38:42
【问题描述】:
我已经验证了 json 正在使用 jsonlint 返回并且它是有效的。举个简单的例子,
"JSONDataResult": "{ \"?xml\":{\"@version\":\"1.0\",\"@encoding\":\"utf-8\"},\"Root\":{\"Information\":{\"Error\":{\"ErrorNo\":\"0\",\"ErrorMsg\":null},\"Address\":{\"Address\":[{\"@AddressID\":\"1232233\",\"@Sequence\":\"1\",\"@Description\":\"Company, Building, 11 Street, County, City\"}
...更多数据和所有正确的标签等
使用下面的方法返回上面的数据结构,但是我不能把它分解成它的组件。
$.getJSON('http://localhost/WcfRestService/RestServiceImpl.svc/json/mypostcode',
function (data) {
//tried all sorts of variations of this sort of thing: data.Root.Information.Address.Address[0]
});
任何想法将不胜感激。
【问题讨论】:
-
当您粘贴的 JSON 无效:jsonformatter.curiousconcept.com
-
你应该提供更多关于它的信息。
-
我想从每个地址字段中获取地址。此刻没有快乐。
-
你接受的this answer有什么问题?
-
现在 json 是通过 wcf rest 服务而不是 http 处理程序返回的,它只是没有它。