2017-04-24 58 views
-1

我必須有數據作爲一個JSON對象:如何JSON數據轉換爲HTML

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

我想JSON數據轉換成使用Javascript或Java中的HTML表格。有人可以提出一種方法如何做到這一點?

任何意見將是有益的。在此先感謝

回答

0

我建議您閱讀JavaScript節點並從JavaScript創建新的HTML元素。當你知道基礎知識時,你可以瀏覽你的對象並創建新的行和列並將它們添加到頁面中。

看看這個鏈接:HTML Nodes from W3Schools

而且我相信這個問題已經被問:Older question