JSON.net has @ in the attribute names?

天涯浪子 提交于 2020-01-10 05:08:37

问题


I am using JSON.NET and I want to convert from XML to JSON.

I am using JsonConvert.SerializeXNode(node) and I noticed that my json object has properties with @ in front of their names:

So for example: If I have:

<channel id="999" name="XXX" sid="8294" type="Digital TV" />

the JSON object is:

{ "@id": "999", @name="XXX" etc

Why am I getting "@" inserted in the JSON and is there a way I can avoid the "@" character being inserted?


回答1:


I think thats just the way json.net works regarding the @ signs. You can always run a regex on the json string and replace them. Theres an example here



来源:https://stackoverflow.com/questions/11017448/json-net-has-in-the-attribute-names

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!