我有一个在我的网站上动态变化的字符串示例:
"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."}},
我试图在我的网站上列出"标题" 的所有值,如下所示:
这是我的代码,但它不起作用:
<p id="output"></p>
<script>
obj = JSON.parse(text);
document.getElementById("output").innerHTML =
obj.Included[1].header;
</script>
有什么想法吗?