1、引用
using System.Web.Script.Serialization;
2、定义类
class FaceCallback { public string device_id { get; set; } public int pass_status { get; set; } public string timestamp { get; set; } public string user_id { get; set; } }
3、转换为类对象
JavaScriptSerializer js = new JavaScriptSerializer(); //实例化一个能够序列化数据的类 FaceCallback faceCallback = js.Deserialize<FaceCallback>(content);//content为json格式数据
string deviceId=faceCallback.device_id;