I’m iterating through this object:
var object = {
first : {
child1 : 'test1',
child2 : 'test2'
},
second : {
child1 : 'test3',
child2 : 'test4'
},
first : {
child1 : 'test5',
child2 : 'test6!'
}
};
with this:
for(var attribute in object){
alert(attribute + " : " + object[attribute]);
}
First it seemed that it works, but it iterates only on child objects with unique name, so the first object with: first is skipped.
JavaScript objects are associative maps, and cannot have multiple values with the same key (name). Your data cannot have that structure.
Another option might be an array of key-value pairs.