我只想问一下如何获取JSON表的当前总行数。我是JSON的新手所以我希望有人会回答我的问题。谢谢..
答案 0 :(得分:5)
<!DOCTYPE html>
<html>
<body>
<h2>Create Object from JSON String</h2>
<p id="demo"></p>
<script>
var text = '{"employees":[' +
'{"firstName":"John","lastName":"Doe" },' +
'{"firstName":"Anna","lastName":"Smith" },' +
'{"firstName":"Peter","lastName":"Jones" }]}';
obj = JSON.parse(text);
document.getElementById("demo").innerHTML =
obj.employees[0].firstName + " " + obj.employees[0].lastName;
</script>
</body>
</html>