MVC JsonResult 返回json问题
return Json(json, JsonRequestBehavior.AllowGet);为什么返回的是{"Uid":3,"AGid":0,"Rid":0,"UserName":"xxx","PassWord":"e10adc3949ba59abbe56e057f20f883e","TrueName":"name","Sex":1,"Tel":"13428673730","Sort":1,"ULid":1,"Status":1,"AddTime":"\/Date(1378173600000)\/","Pic":null,"Remark":null,"EntityState":2,"EntityKey":{"EntitySetName":"Admin","EntityContainerName":"WCFTestEntities","EntityKeyValues":[{"Key":"Uid","Value":3}],"IsTemporary":false}}
这些,"EntityState":2,"EntityKey":{"EntitySetName":"Admin","EntityContainerName":"WCFTestEntities","EntityKeyValues":[{"Key":"Uid","Value":3}],"IsTemporary":false是怎么来的,怎么过滤掉这些呢,烦请各位帮忙看看,谢谢。 --------------------编程问答-------------------- return Json(object) 会把object里的所有属性都反射出来
不想都返回的话就创建一个只有需要返回属性的对象
如果object是集合
return Json(object.select(a=>new {id=a.id,name=a.name}));
如果是对象
return Json(new {id=obj.id,name=obj.name}) --------------------编程问答-------------------- 同意一楼,也就是自己返回一个业务类,返回到前台,让前台接收 --------------------编程问答--------------------
+1
补充:.NET技术 , ASP.NET