Josn实体类如下:
public class Result
{
public int StatusCode { get; set; }
public string Message { get; set; }
}
传真操作方法如下:
Result result = new Result { StatusCode = , Message = "操作失败", IsSucceed=false };
JavaScriptSerializer serializer = new JavaScriptSerializer();
string strResult= serializer.Serialize(result);
相当于如下方法:
public string success()
{
return "{\"statusCode\":\"200\", \"message\":\"操作成功!\"}";