【发布时间】:2016-02-04 23:05:50
【问题描述】:
我在 json.net.. 的帮助下序列化 XML 文档。
一些 XML 元素具有属性,所以当我使用时:
JsonConvert.SerializeXNode(xml, Newtonsoft.Json.Formatting.None, true);
XML 元素<shipmentIndex Name="items">0</shipmentIndex>
转换为该 JSON:
{"shipmentIndex":{"@Name":"items","#text":"0"}
我正在将此 JSON 发送到一个 API,该 API 需要这样的东西:
{"shipmentIndex":0}
如何向 API 发送正确的数据?
- 我使用属性来根据 API 要求格式化 JSON。
【问题讨论】: