【发布时间】:2014-02-18 13:17:32
【问题描述】:
我正在将 XML 文档转换为 JSON。
我有一个可以是多个节点的节点。
Json.Net documentation 表示要强制将节点序列化为数组,我应该添加 json:array=true 属性。
在我的根节点上添加 json 命名空间:
writer.WriteAttributeString("xmlns", "json", null, "http://james.newtonking.com/json");
然后在我需要成为数组的元素上添加json:array=true 属性:
writer.WriteAttributeString("Array", "http://james.newtonking.com/json", "true");
XML 看起来像预期的那样:
<result xmlns:json="http://james.newtonking.com/json">
<object json:Array="true">
但 JSON 看起来像这样:
"result": {
"@xmlns:json": "http://james.newtonking.com/json",
"object": {
"@json:Array": "true",
我做错了什么?
【问题讨论】: