【问题标题】:Proper JSON formatting a C# String正确格式化 C# 字符串的 JSON
【发布时间】:2009-05-02 03:27:23
【问题描述】:

如果你在 MVC 中这样做:

var jsonData = 
    new { myimage = 
        "<img alt=\"\" src=\"/Content/images/ShowFPots.png\" />" };

return Json(jsonData);

你得到这个作为一个值

"\u003cimg alt=\"\" src=\"/Content/images/ShowFPots.png\" /\u003e"

我如何将它作为一个值,或者当我将它们添加到 innerHtml 时 是否会正确解释??

"<img alt=\"\" src=\"/Content/images/ShowFPots.png\" />"

【问题讨论】:

    标签: c# json unicode


    【解决方案1】:

    那是正确的 javascript,unicode 编码。将其插入 html/DOM 就可以了

    https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Unicode

    【讨论】:

    • 是插入的内容。 是正确的,但在结束标记 (/>) 之前缺少 /。奇数。
    • 这很可能是浏览器/DOM 操作 html,但您可以在问题中看到字符串末尾的 /
    猜你喜欢
    • 2017-09-25
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    • 1970-01-01
    • 2018-01-01
    • 2021-11-24
    • 2016-06-22
    • 1970-01-01
    相关资源
    最近更新 更多