0
我有一个JSON字符串,我需要创建C#类,然后以类似的格式解析整个List。 JSON字符串包含“0”和“1”。我已注解类的属性与编写自定义c#类来表示JSON?
[JsonProperty( “0”)]
但看起来像它不工作。
{
"draw": 4,
"recordsTotal": 57,
"recordsFiltered": 57,
"data": [
{
"0": "Charde",
"1": "Marshall",
"2": "Regional Director",
"3": "San Francisco",
"4": "16th Oct 08",
"5": "$470,600",
"DT_RowId": "row_13"
},
{
"0": "Colleen",
"1": "Hurst",
"2": "Javascript Developer",
"3": "San Francisco",
"4": "15th Sep 09",
"5": "$205,500",
"DT_RowId": "row_9"
},
{
"0": "Dai",
"1": "Rios",
"2": "Personnel Lead",
"3": "Edinburgh",
"4": "26th Sep 12",
"5": "$217,500",
"DT_RowId": "row_20"
}]
}
类,我已经尝试了这个JSON
public class UserData
{
[JsonProperty("0")]
public string Name { get; set; }
[JsonProperty("1")]
public string Email { get; set; }
//Having more JSON properites
[JsonProperty("DT_RowId")]
public long UserId { get; set; }
}
public class JsonValdate
{
public string draw { get; set; }
public int length { get; set; }
public int start { get; set; }
public int recordsFiltered { get; set; }
public int recordsTotal { get; set; }
[JsonProperty("data")]
public UserData[] data { get; set; }
}
我已经将UserId long转换为字符串,而Json转换。它工作正常。数据数组索引中没有“0”和“1”。 thx – user223372 2014-08-28 17:04:59
我更新了如何调试的答案。 – Win 2014-08-28 17:14:14