前台传过来的不是一个对象,而是一个Json字符串怎么办 ?
如:
{"fids":"2323","contents":"<p>lsdfjlsdjflsdf</p>"}
处理方法已经贴出来了,用JObject 来处理
public ActionResult Update(string param2) { JObject job = (JObject)JsonConvert.DeserializeObject(param2); CustomerFollowEntity follow = new CustomerFollowEntity(); follow.F_Id = job["fids"].ToString(); follow.F_Description = job["contents"].ToString(); int s = custapp.Update(follow); return Content(s.ToString()); }
要引用命名空间
using Newtonsoft; using Newtonsoft.Json; using Newtonsoft.Json.Linq;