WebApi返回json
Api
[HttpPost] public object ReceiveFile() { string json = DisptcherHelper.Instance.Start(); return new HttpResponseMessage { Content = new StringContent(json, Encoding.GetEncoding("UTF-8"), "application/json") }; }
接收到字符串:
"{\"result\":false,\"code\":\"\",\"msg\":\"缺少机构参数,请检查输入\",\"data\":null}"
转换成Json:
var json = eval('(' + data + ')'); console.log(JSON.stringify(json));
转换成Json后输出:
{"result":false,"code":"","msg":"缺少机构参数,请检查输入","data":null}