当我将Json对象转换为c#时,我遇到了一个问题,其中我的Json的字段带有$符号(例如:$ t).但是c#不接受带有特殊字符的字段.如果我尝试用我的c#代码中的任何其他字母替换$,由于命名的变化,我无法从第三方获取数据.
我该如何解决这个问题?
Json字符串:
"author": [(1)
{
"name": {
"$t": "theabctv"
},-
"uri": {
$t": "http://gdata.abc.com/feeds/api/users/theabctv"
},-
"yt$userId": {
"$t": "tCUABCCT7wYG1PMCpw"
}-
}-
],-
Run Code Online (Sandbox Code Playgroud)
C#代码: -
public class Author2
{
public Name2 name { get; set; }
public Uri2 uri { get; set; }
public YtUserId __invalid_name__yt$userId { get; set; }
}
public class Name2
{
public string __invalid_name__$t { get; set; }
}
public class Uri2
{
public string __invalid_name__$t { get; set; }
}
public class YtUserId
{ …Run Code Online (Sandbox Code Playgroud)