当前位置:淘百问>百科知识>怎么获取json数据

怎么获取json数据

2024-07-20 11:10:38 编辑:join 浏览量:578

怎么获取json数据

获取json数据

<script>

varjson=

[{"nam物报环e":"Lee","sex":"male"},{"age":"21","hobit":"baskeyball"}]

alert(json[0].name)

//json[0]就是{"name":"Lee","sex":"male"}

//json[1]就是{"age":"21","hobit":"baskeyball"}

</script>

 

<script>

Va来自rjson=

[{"name":[{"firstna夫味振美新被王许汉me":"Lee","lastname":"min"}],"sex":"male"},{"age":"21","hobit":"baskeyball"}]

alert(jso述花终热n[0].name[0].firstname);

//json[0]就是{"name":"Lee","sex":"male"}

//json[0].name[0]就是{"firstname":"Lee","lastname":"min"}

//json[1]就是{"age":"21","hobit":"baskeyball"}

</script>

补脑专用:json一般是对象的集合,相当于java的list集合立一样,

语法:varjson=[策以项低杆晚怎{"name":"Lee","s360问答ex":"male"},{"hobit":"tennis"}]

 //json最外面是中括号,里面是由花括号组成的对象,对象之间用逗号隔开,对象快渐西推取里面有属性,属性之间以逗号隔开

标签:json,获取,数据

版权声明:文章由 淘百问 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.taobaiwen.com/article/445052.html
热门文章