I have am array like this:
var jsonObj = {
"name": "my boards",
"children": [
{
"name": "AAA",
"children": [
{
"name": "AAA_2",
"size": 422
},
{
"name": "AAA_2",
"size": 422
},
{
"name": "AAA_2",
"size": 422
}
]
},
{
"name": "BBB",
"children": [
{
"name": "BBB_2",
"size": 422
},
{
"name": "BBB_2",
"size": 422
},
{
"name": "BBB_2",
"size": 422
}
]
},
{
"name": "CCC",
"children": [
{
"name": "CCC_2",
"size": 422
},
{
"name": "CCC_2",
"size": 422
},
{
"name": "CCC_2",
"size": 422
}
]
}
]
}
And I want to use jquery to fill this object with values inside divs. I think I am getting the dots and brackets wrong. I am trying this:
function fill_object() {
$.each($('.my_div'), function() {
jsonObj.children["name"] = $(this.id).value();
jsonObj.children.children["name"] = $(this.id).value();
});
return (jsonObj)
}
But I get the following error:
Uncaught TypeError: Cannot read property 'children' of undefined
I want to be able to add values to AAA, AAA_2, BBB, BBB_2, CCC and CCC_2