string strPost = new Utils().getPost(context); var obj = new { name = "",age = "" }; obj = JSONHelper.JsonToObject(strPost,obj);
public string getPost(HttpContext context) { return new StreamReader(context.Request.InputStream).ReadToEnd(); }
public static T JsonToObject<T>(string json,T anonymousTypeObject) { T t = JsonConvert.DeserializeAnonymousType(json,anonymousTypeObject); return t; }好处:懒人多作怪,不用建model