关于json长度的问题,求助
json一般由中括号[]括起来,里面放的是一些对象,对象用花括号{},对象之间以逗号区分,对象里面又有属性,属性之间由逗号区分,如下
2.获取json数据
<script>
var json =
[{"name":"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>
Var json =
[{"name":[{"firstname":"Lee","lastname":"min"}],"sex":"male"},{"age":"21","hobit":"baskeyball"}]
alert(json[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>
<script>
var json = [{"recommand_stock_history_id": 49,
"ref_strategies":[{"strategy_id":605,"strategy_name":"hello4","profit":-16.44}]
}]
var arr = json[0].ref_strategies[0].strategy_id;
alert(arr)
</script>