假设 js 是您选择的工具,并且由于您没有说明要对数组做什么,因此只需分配给一个名为 var 的变量obj
,您就可以访问它 - 根据需要循环...
<!DOCTYPE HTML>
<html>
<body>
<h2>Manage a JSON Object in JavaScript</h2>
<p id="demo"></p>
<script>
var obj = [{"id":"787381","t":"HDFC","e":"NSE","l":"1,424.00","l_fix":"1424.00","l_cur":"₹1,424.00","s":"0","ltt":"3:46PM GMT+5:30","lt":"Sep 23, 3:46PM GMT+5:30","lt_dts":"2016-09-23T15:46:54Z","c":"+10.75","c_fix":"10.75","cp":"0.76","cp_fix":"0.76","ccol":"chg","pcls_fix":"1413.25"}];
document.getElementById("demo").innerHTML =
obj[0].id + "<br>" +
obj[0].t + "<br>" +
obj[0].e + "<br>" +
obj[0].l + "<br>" +
obj[0].l_fix + "<br>" +
obj[0].l_cur + "<br>" +
obj[0].s + "<br>" +
obj[0].ltt + "<br>" +
obj[0].lt + "<br>" +
obj[0].lt_dts + "<br>" +
obj[0].c + "<br>" +
obj[0].c_fix + "<br>" +
obj[0].cp + "<br>" +
obj[0].cp_fix + "<br>" +
obj[0].ccol + "<br>" +
obj[0].pcls_fix + "<br>";
</script>
</body>
</html>
结果到浏览器的输出是:
Accessing a JSON Object in JavaScript
787381
HDFC
NSE
1,424.00
1424.00
₹1,424.00
0
3:46PM GMT+5:30
Sep 23, 3:46PM GMT+5:30
2016-09-23T15:46:54Z
+10.75
10.75
0.76
0.76
chg
1413.25