當前位置:成語大全網 - 書法字典 - jquery遍歷json插入數組的問題

jquery遍歷json插入數組的問題

//?被誰?雨夾雪?2016/05/10

var?RES =' {"list": [{"ID": 3010," Name ":"青海"," city list ":[{"ID ":3011," Name ":"西寧" },{ " ID。

var?dataObj?=?JSON . parse(RES);

var?listData?=?data obj . list;

var?cityAry?=?[];

for(var?I = 0;我& ltlistData.lengthi++){

var?tmp?=?list data[I];

var?城市?=?{

值:tmp.id,

text:tmp.name,

兒童:[]

}

for(var?j = 0;j & lttmp . city list . length;j++){

city.children.push({

值:tmp.cityList[j]。id,

text:tmp.cityList[j]。名字

})

}

cityAry.push(城市);

}

console . table(city ary);