在reactjs里面怎么解析json,比如 { a:"a",b:[{c:"c",d:"d" }] }
<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>
[
{
"recommand_stock_history_id": 49,
"ref_strategies": "[{\"strategy_id\":605,\"strategy_name\":\"hello4\",\"profit\":-16.44}]",
}
] 如何获得 strategy——id?
<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> //我将json里面的格式改了一下,如果非要用你原来的json格式的话,就真的抱歉了,