javascript - 在 JSON 中写入 HTML 字符串

标签 javascript jquery html json

是否可以在 JSON 中写入 HTML 字符串?

我想在我的 JSON 文件中像下面这样写:

[
    {
        "id": "services.html",
        "img": "img/SolutionInnerbananer.jpg",
        "html": "<h2class="fg-white">AboutUs</h2><pclass="fg-white">developing and supporting complex IT solutions.Touchingmillions of lives world wide by bringing in innovative technology </p>"
    }
]

最佳答案

您应该通过添加 "\"来转义 html 字符串中的双引号等字符

例如:<h2 class=\"fg-white\">

关于javascript - 在 JSON 中写入 HTML 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22551586/

相关文章:

html - 在 Foundation 6 XY 网格中决定何时需要新的 grid-x "row"

html - <img> 和 <label> 标签在同一行

javascript - 修复 Javascript 中的反射 XSS 问题。 CheckMarx

javascript - 我可以将 javascript 对象数据渲染到 c3js 图表中吗?

javascript - 使用 .click() 模拟文件输入点击在 iOS 中不起作用 - Cordova

javascript - Jquery 递增数字,限制为 5

javascript - 内置 Phonegap 的应用程序 - 如何使元素可拖动?

javascript - 让 jQuery .click() 激活不止一次

javascript - 需要 JS : object is not a function (when calling form. submit()) 中的解决方法

php - jQuery 转义空格