//方法1
string mStr1 = "[{\"name\":\"李四\",\"age\":22,\"classroom\":\"102\"}]";
//这是转为实体集合
List<Student> students = JsonConvert.DeserializeObject<List<Student>>(mStr1);
//这是转为单个实体
mStr1 = "{\"name\":\"李四\",\"age\":22,\"classroom\":\"102\"}";
var student = JsonConvert.DeserializeObject<Student>(mStr1);
//方法2
//JavaScriptSerializer所属命名空间System.Web.Script.Serialization
JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
string mStr1 = "{\"name\":\"李四\",\"age\":22,\"classroom\":\"102\"}";
Student mStudent1 = javaScriptSerializer.Deserialize<Student>(mStr1);
Console.WriteLine(mStudent1.Name);
public class Student
{
/// <summary>
/// 姓名
/// </summary>
public string Name { get; set; }
/// <summary>
/// 年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 班级
/// </summary>
public string Classroom { get; set; }
}