我正在研究 json,我想知道这是否是编写嵌套的多维 json 对象的正确方法。我写道:
var foo = {
"logged_in":true,
"town":"Dublin",
"state":"Ohio",
"country":"USA",
"products":2,
"0":{
"pic_id":"1500",
"description":"Picture of a computer",
"localion":"img.cloudimages.us/2012/06/02/computer.jpg",
"type":"jpg",
"childrenimages":2
"0":{
"pic_id":"15011",
"description":"Picture of a cpu",
"localion":"img.cloudimages.us/2012/06/02/mycpu.png",
"type":"png"
}
"1":{
"pic_id":"15012",
"description":"Picture of a cpu two",
"localion":"img.cloudimages.us/2012/06/02/thiscpu.png",
"type":"png"
}
},
"1":{
"pic_id":"1501",
"description":"Picture of a cpu",
"localion":"img.cloudimages.us/2012/06/02/cpu.png",
"type":"png"
}
};
如果我的对象嵌套太深,这是对的还是我应该遵循的约定。