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
{
- public string name
- { get; set; }
- public int age
- { get; set; }
}
List<Student> students = JsonConvert.DeserializeObject<List<Student>>(json);
foreach (Student model in students)
{
//dosomething
}