下面是我的json字符串,我试图解析我的班级列表
我正在使用NewtonsJson.net.3.5
[
{
"message": {
"$": "@12:55 Big Rally on South Bound of Dr. B.A. Road. Motorists may use RAK Road, P. D'Melow Road & A.B. Road for CST.\n -visit icicilombard.com"
},
"picture": {
"$": ""
},
"medium": {
"$": "API"
},
"timestamp": {
"$": "03\/15\/2011 12:55:42 IST"
}
}
]
这是我的课程,我希望将我的json解析为
public class GupShupTrafficAlerts
{
private string _message = string.Empty;
private string _picture = string.Empty;
private string _medium = string.Empty;
private string _timeStamp = string.Empty;
public String message
{
get;
set;
}
public string timestamp
{
get;
set;
}
public string medium
{
get;
set;
}
public string picture
{
get;
set;
}
}
这是我尝试解析List
的方式List<GupShupTrafficAlerts> lstTrafficAlert =
JsonConvert.DeserializeObject<List<GupShupTrafficAlerts>>(@JSonString);
但无济于事 请帮帮我......
答案 0 :(得分:3)
你的JSON应该是这样的:
[
{
"message": "@12:55 Big Rally on South Bound of Dr. B.A. Road. Motorists may use RAK Road, P. D'Melow Road & A.B. Road for CST.\n -visit icicilombard.com",
"picture": "",
"medium": "API",
"timestamp":"03\/15\/2011 12:55:42 IST"
}
]