我有这个json -
[{"a":"2958081","b":"Contact Sport","e":"abc4 news sport recent","f":[{"a":"831081","f":"2011-09-30 23:00:00","g":"2011-10-14 23:00:00"},{"a":"831080","f":"2011-09-23 23:00:00","g":"2011-10-07 23:00:00"}]},{"a":"2959838","b":"ABC National Evening News","e":"news abc4 recent last-chance","f":[{"a":"831928","f":"2011-09-30 23:00:00","g":"2011-10-01 22:00:00"}]}]
给出了一个异常
"意外状态:已完成。1号线,206号位置。"
,代码如下:
doc = CType(Newtonsoft.Json.JsonConvert.DeserializeXmlNode(json, "root"), XmlDocument)
json
为string
, doc
为XmlDocument
是否有一种方法来处理这些重复的数组结构?我只展示了2,完整的JSON文件(字符串)有~250(总共75K字节)。在显示的代码片段之前,将包含整个的[]去掉。
@VoidMain在CodePlex JSON中提供了一个解决方案。净的讨论。
它需要对字符串进行轻微的编辑,在前面挂起{object:并像上面写的那样在json后面附加}。
{objects:[{"a":"2958081","b":"Contact Sport","e":"abc4 news sport recent","f":[{"a":"831081","f":"2011-09-30 23:00:00","g":"2011-10-14 23:00:00"},{"a":"831080","f":"2011-09-23 23:00:00","g":"2011-10-07 23:00:00"}]},{"a":"2959838","b":"ABC National Evening News","e":"news abc4 recent last-chance","f":[{"a":"831928","f":"2011-09-30 23:00:00","g":"2011-10-01 22:00:00"}]}]}