我想你想得到如下的 JSON 字符串:
{
'RegistrationList': [
{
'CaseNumber': '120654-1330',
'Priority': 5,
'PersonId': 7,
'Person': {
'FirstName': '0',
'LastName': '',
},
'UserId': 7,
'User': {
'Id': 7,
'CreatedTime': '2013-07-05T13:09:57.87',
'Comment': ''
}
},
{
'CaseNumber': '120654-1330',
'Priority': 5,
'PersonId': 7,
'Person': {
'FirstName': '0',
'LastName': '',
},
'UserId': 7,
'User': {
'Id': 7,
'CreatedTime': '2013-07-05T13:09:57.87',
'Comment': ''
}
},
]
}
如果是这样,您可以获得以下代码来解决您的问题:
string json = @"{
'RegistrationList': [
{
'CaseNumber': '120654-1330',
'Priority': 5,
'PersonId': 7,
'Person': {
'FirstName': '0',
'LastName': '',
},
'UserId': 7,
'User': {
'Id': 7,
'CreatedTime': '2013-07-05T13:09:57.87',
'Comment': ''
}
},
{
'CaseNumber': '120654-1330',
'Priority': 5,
'PersonId': 7,
'Person': {
'FirstName': '0',
'LastName': '',
},
'UserId': 7,
'User': {
'Id': 7,
'CreatedTime': '2013-07-05T13:09:57.87',
'Comment': ''
}
},
]
}";
JObject o = JObject.Parse(json);
JArray list = (JArray)o["RegistrationList"];
List<Tuple<string, string, string>> rList = new List<Tuple<string, string, string>>();
foreach (var r in list)
{
Tuple<string, string, string> temp = new Tuple<string, string, string>(r["CaseNumber"].Value<string>(), r["Person"]["FirstName"].Value<string>(), r["User"]["Comment"].Value<string>());
rList.Add(temp);
Console.WriteLine(temp);
}