Forum Moderators: open
Item.includes['left'] // An array of IDs of included items
Item.includes['right'] // Same
Item.price // Item price
Then I convert it using:
Item.toJSONString() // From http://www.json.org/json.js
{"price":123,"includes":[]}
Item.includes, does anyone know how I can convert the object to JSON and get all of the arrays as well?
Without seeing your entire code, I'd say this piece doesn't do what you think it does. You have an object "Item" which has a property "includes". "includes" is an object which has properties "left" and "right". "left" and "right" both contain arrays of ids. So that might look like this:
var Item = {
"includes" : {
"left" : [1,2,3],
"right" : [4,5,6]
},
"price" : "$1.00"
};
You get back this:
{"price":123,"includes":[]}
That indicates that "includes" contains an array, NOT another object like your syntax above suggests. If that's true, then your syntax of:
Item.includes['left']
and
Item.includes['right']
is incorrect (what index does the string 'left' and 'right' correspond to if this is an array?)