首页 > > > c#生成json对象
public static string api_return(bool status=true, string message="ok", Object custom_ary=null, string errorCode="")
{
System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
Dictionary result = new Dictionary();
result["status"] = status ? "success" : "error";
result["message"] = message;
if (!status)
{
result["errorCode"] = errorCode;
}
result["data"] = custom_ary;
return jss.Serialize(result);
}
注意需要添加引用(非web项目):system.web.extension
原文作者:;如有侵权,请联系管理员删除。