JSON.net在属性名称中有@吗? [英] JSON.net has @ in the attribute names?

查看:70
本文介绍了JSON.net在属性名称中有@吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JSON.NET,并且想要从XML转换为JSON.

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

我正在使用JsonConvert.SerializeXNode(node),我注意到我的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" />

JSON对象是:

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

为什么我要在JSON中插入"@",有什么方法可以避免插入"@"字符?

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

推荐答案

我认为这就是json.net关于@符号的工作方式.您始终可以在json字符串上运行正则表达式并替换它们.在此处

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

这篇关于JSON.net在属性名称中有@吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆