string json=“[{“name”:”zhangsan”,”age”:”12”},{“name”:”zhangsan”,”age”:”12”}]”
方法1:
JArray arr = (JArray)JsonConvert.DeserializeObject(json);
JObject obj = (JObject)arr[1];
Console.WriteLine(obj["name"]);
Console.WriteLine(arr[1]["name"]);
方法2
一个对象
public class Student
{
}
List<Student> students = JsonConvert.DeserializeObject<List<Student>>(json);
foreach (Student model in students)
{
//dosomething
}
时间: 2024-10-13 17:04:11