【问题标题】:How to convert JSON data to Html如何将 JSON 数据转换为 Html
【发布时间】:2017-09-20 22:43:59
【问题描述】:

我有一个 json 对象,其数据为:

[
    {
        "help": "Required ARIA attributes must be provided",
        "nodes": [
            {
                "all": [],
                "impact": "critical",
                "html": "<input id=\"chkPrvt\" onclick=\"clkSec()\" name=\"trusted\" value=\"4\" type=\"checkbox\" class=\"chk\" role=\"checkbox\" aria-labelledby=\"privateLabel\">",
                "none": [],
                "any": [
                    {
                        "data": [
                            "aria-checked"
                        ],
                        "impact": "critical",
                        "relatedNodes": [],
                        "id": "aria-required-attr",
                        "message": "Required ARIA attribute not present: aria-checked"
                    }
                ],
                "target": [
                    "#chkPrvt"
                ]
            },
            {
                "all": [],
                "impact": "critical",
                "html": "<input id=\"chkBsc\" type=\"checkbox\" onclick=\"clkBsc();\" class=\"chk\" role=\"checkbox\" aria-labelledby=\"lightLabel\">",
                "none": [],
                "any": [
                    {
                        "data": [
                            "aria-checked"
                        ],
                        "impact": "critical",
                        "relatedNodes": [],
                        "id": "aria-required-attr",
                        "message": "Required ARIA attribute not present: aria-checked"
                    }
                ],
                "target": [
                    "#chkBsc"
                ]
            }
        ],
        "impact": "critical",
        "description": "Ensures elements with ARIA roles have all required ARIA attributes",
        "helpUrl": "https://dequeuniversity.com/rules/axe/2.1/aria-required-attr?application=axeAPI",
        "id": "aria-required-attr",
        "tags": [
            "wcag2a",
            "wcag411",
            "wcag412"
        ]
    }
]

我想使用 Javascript 或 Java 将 JSON 数据转换为 HTML 表格。有人可以建议一种方法吗?

对此的任何建议都会有所帮助。提前致谢

【问题讨论】:

    标签: javascript arrays json parsing html-table


    【解决方案1】:

    我建议您阅读有关 JavaScript 节点和从 JavaScript 创建新 HTML 元素的内容。当您了解基本知识后,您可以浏览您的对象并创建新的行和列并将它们添加到页面中。

    看看这个链接:HTML Nodes from W3Schools

    我相信这个问题已经被问到了:Older question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-14
      • 2014-10-28
      • 2018-03-04
      • 2019-11-24
      • 2011-10-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多