当你的才华不能撑起你的野心时,就是你该选择学习的时候了!

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}

 

posted @ 2020-04-25 12:40  hofmann  阅读(228)  评论(0编辑  收藏  举报