示例 1 :
创建JSON数组
通过方括号[] 创建JSON 数组
<script> var heros= [ {"name":"盖伦","hp":616}, {"name":"提莫","hp":313}, {"name":"死歌","hp":432}, {"name":"火女","hp":389} ] document.write("JSON数组大小"+heros.length); </script>
示例 2 :
访问JSON数组
访问JSON数组和访问普通数组一样,通过下标访问
<script> var heros= [ {"name":"盖伦","hp":616}, {"name":"提莫","hp":313}, {"name":"死哥","hp":432}, {"name":"火女","hp":389} ] document.write( "第4个英雄是:" + heros[3].name); </script>
示例 3:
数组里包含对象:
可以用json.cn 来做json的校验