Is this a javascript array with objects in it?
Square brackets is an array, and curly brackets are objects correct?
What exactly is this data structure:
Some.thing = [ {
"swatch_src" : "/images/91388044000.jpg",
"color" : "black multi",
"inventory" : {
"F" : [ 797113, 797114 ],
"X" : [ 797111, 797112 ]
},
"images" : [ {
"postfix" : "jpg?53_1291146215000",
"prefix" : "/images/share/uploads/0000/0000/5244/52445892"
}, {
"postfix" : "jpg?53_1291146217000",
"prefix" : "/images/share/uploads/0000/0000/5244/52445904"
}, {
"postfix" : "jpg?53_1291146218000",
"prefix" : "/images/share/uploads/0000/0000/5244/52445909"
} ],
"skus" : [ {
"sale_price" : 199,
"sku_id" : 797111,
"msrp_price" : 428,
"size" : "s"
}, {
"sale_price" : 199,
"sku_id" : 797112,
"msrp_price" : 428,
"size" : "m"
}, {
"sale_price" : 199,
"sku_id" : 797113,
"msrp_price" : 428,
"size" : "l"
}, {
"sale_price" : 199,
开发者_Go百科 "sku_id" : 797114,
"msrp_price" : 428,
"size" : "xl"
} ],
"look_id" : 37731360
} ];;
Some.thing
is an array []
containing a single object {}
. Some of the properties of this object are strings while others are arrays.
The single object appears to be describing a product.
Yes, an array of objects with nested arrays within. (or in this case one single element contained within an array.)
Some.thing[0]
refers to everything you have listed. From there, you have an object containing:
var obj = Some.thing[0];
obj.swatch_src // contains "/images/91388044000.jpg"
obj.color // contains "black multi"
...
obj.inventory // (another object
obj.inventory.F // array of [797113, 797114]
...
obj.images // array of objects
obj.images[0].postfix // contains "jpg?53_1291146215000"
obj.images[0].prefix // contains "/images/share/uploads/0000/0000/5244/52445892"
...
This is captured from Chrome Console. You can try it yourself :)
Yes, this is called JSON: JavaScript Object Notation.
精彩评论