从动态JSON字符串和样式创建对象

时间:2016-11-02 11:01:44

标签: javascript arrays json xml attributes

我有一个在我的网站上动态变化的字符串示例:

"TermsOfService":{"Included":[{"@attributes":{"header":"2 Design Concepts","details":"Unique concepts provided to you"}},{"@attributes":{"header":"Unlimited Revisions","details":"Revise until you are happy"}},{"@attributes":{"header":"Vector Files","details":"Final logo will be in vector file"}},{"@attributes":{"header":"Fast Turnaround","details":"No time wasting. Ready in just five days."}},

我试图在我的网站上列出"标题" 的所有值,如下所示:

  • 2设计概念
  • 无限修订
  • 矢量文件
  • 快速周转

这是我的代码,但它不起作用:

<p id="output"></p>
<script>
obj = JSON.parse(text);
document.getElementById("output").innerHTML =
obj.Included[1].header;
</script>

有什么想法吗?

0 个答案:

没有答案