在json中写入html字符串 [英] Write html string in json

查看:471
本文介绍了在json中写入html字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我可以在JSON文件中编写如下的代码:

  [
{
id:services.html,
img:img / SolutionInnerbananer.jpg,
html:< h2class =fg-white> AboutUs< / h2>< pclass =fg-white>开发和支持复杂的IT解决方案。技术< / p>


$ / code $ / pre

解决方案

您应该通过添加 \ 来避免html字符串中的双引号字符。

class = \fg-white \>


Is it possible write a HTMLstring inside JSON ?

Which I want to write like below in my json file

[
    {
        "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>"
    }
]

解决方案

You should escape the characters like double quotes in the html string by adding "\"

eg: <h2 class=\"fg-white\">

这篇关于在json中写入html字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆