属性名称中的特殊字符 [英] Special characters in property name
本文介绍了属性名称中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,网络服务将返回json
In my Application a webservice will return a json
{
"UserDetails": [
{
"UserId": "57",
"EmailId": "prasant@xyz.com",
"UserName": "Prasant",
"TimezoneMins": "330",
"CustomLogo": "",
"IsExecutive": "True",
"HasNTID": "1",
"Org_Id": "1",
"Org_Name": "Summit",
"Designation": null,
"Location": null,
"Location_Name": "",
"WsVersion": "V5.1.0",
"CallMe": "FALSE",
"GPS": "FALSE",
"Feedback_IM&SR": "NULL",
"RPT_Widgets_Access": "False"
}
] }
在这里,我想将此json反序列化为类对象.其中的类包含与json中的键相同的属性.
Here i want to Deserialize this json into a class object. In which the class contains the properties same as the keys in json.
public class UserDetails
{
int? _userId;
string _emailId;
string _userName;
int _timezoneMins;
string _customLogo;
string _isExecutive;
int _hasNTID;
int? _org_Id;
string _org_Name;
string _designation;
int? _location;
string _location_Name;
string _feedback_IMSR;
string _rPT_Widgets_Access;
public string Feedback_IM&SR
{
get{return _feedback_IMSR;}
set{_feedback_IMSR = value;}
}
}
此处,变量和属性"Feedback_IM& SR"具有&"变量和属性名称中都不允许使用的字符,但是我需要该属性的值.
Here the variable and property "Feedback_IM&SR" is having '&' character which is not allowed either in variable and Property names,but i need the value of that property.
有人可以帮我吗?
推荐答案
您可以使用以下引用从json创建类对象
You can make class objects from json using following references
只需粘贴您的json字符串,它将在该json内生成C#类和属性.
Just paste your json string and it will generate C# class and properties inside that json.
这篇关于属性名称中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文