相关疑难解决方法(0)

将HTML映射到JSON

我正在尝试将HTML映射到JSON,结构完整.是否有任何图书馆可以做到这一点,还是我需要自己编写?我想如果没有html2json库,我可以把xml2json库作为一个开始.毕竟,html只是xml的一个变种吗?

更新:好的,我应该举一个例子.我想要做的是以下内容.解析一串html:

<div>
  <span>text</span>Text2
</div>
Run Code Online (Sandbox Code Playgroud)

像这样的json对象:

{
  "type" : "div",
  "content" : [
    {
      "type" : "span",
      "content" : [
        "Text2"
      ]
    },
    "Text2"
  ]
}
Run Code Online (Sandbox Code Playgroud)

注意:如果你没有注意到标签,我正在寻找Javascript的解决方案

html javascript json

58
推荐指数
3
解决办法
8万
查看次数

在json中写下html字符串

是否可以在JSON中编写HTMLstring?

我想在我的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>"
    }
]
Run Code Online (Sandbox Code Playgroud)

html javascript jquery json

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

标签 统计

html ×2

javascript ×2

json ×2

jquery ×1