小编Max*_*son的帖子

如何返回带有unicode字符的json结果转义为\ u1234

我正在实现一个返回json结果的方法,如:

public JsonResult MethodName(Guid key){
    var result = ApiHelper.GetData(key); //Data is stored in db as varchar with åäö
    return Json(new { success = true, data = result },"application/json", Encoding.Unicode, JsonRequestBehavior.AllowGet );
}
Run Code Online (Sandbox Code Playgroud)

显示的结果:

{"success":true,"data":[{"Title":"Here could be characters like åäö","Link":"http://www.url.com/test",...},
Run Code Online (Sandbox Code Playgroud)

但我想显示它像:

{"success":true,"data":[{"Title":"Here could be characters like \u00e5\u00e4\u00f6","Link":"http:\/\/www.url.com\/test",...},
Run Code Online (Sandbox Code Playgroud)

我怎么能做到这一点?我可以转换它,解析它或更改web.config中的responseEncoding以使其显示unicode字符吗?

c# unicode asp.net-mvc json

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

json ×1

unicode ×1