测试数据:
var tree_data2 = {}
tree_data2['foodmart'] = {name: 'Foodmart', type: 'folder'}
tree_data2['foodmart']['children']={}
tree_data2['foodmart']['children']['appetizer']={name: 'Appetizer', type: 'item'}
tree_data2['foodmart']['children']['main-course']={name: 'Main Course', type: 'item'}
tree_data2['foodmart']['children']['Drinks']={name: 'Drinks', type: 'folder'}
jquery 方式:
$.each(tree_data2['foodmart']['children'], function(key,value) {
console.log(key+": "+value['name'])})
js 方式:
var jsonv = tree_data2["foodmart"]['children'];
for(var key in jsonv){
console.log(jsonv[key]["name"])
}