I have created this object :
var hemicycle = {
Groupe : "Group1" [{
Member : [{
Name : "MemberName",
Siege : "SiegeNumber",
Vignette : "PhotoURL"
}]
}]
};
I try to display some data from it but I can't access any. When I type hemicycle in the dev tools of Chrome I get this :
I also tried to display "Group1" from the object but it won't let me, I typed this :
I don't know why my object is not defined ?
Any help is appreciated.
3 Answers 3
Well, the issue is, that you actually don't have a valid object. Groupe has really weird structure, what is it supposed to be? Array? Then try this:
var hemicycle = {
Groupe: [{
Member : [{
Name : "MemberName",
Siege : "SiegeNumber",
Vignette : "PhotoURL"
}]
}]
};
1 Comment
Your problem is that your object itself is invalid. Two ways to improve that. Choose whatever fits your needs best.
var hemicycle = {
Groupe : "Group1",
Content : [{
Member : [{
Name : "MemberName",
Siege : "SiegeNumber",
Vignette : "PhotoURL"
}]
}]
};
var hemicycle = {
Groupe : [{
Member : [{
Name : "MemberName",
Siege : "SiegeNumber",
Vignette : "PhotoURL"
}]
}]
};
this simple example should solve your problem
var myObj = {
"1": { address: "44 buxton gardens berea durban", lat: "25.686", lng: "58.1156"},
"2": { address: "44 buxton gardens berea durban", lat: "0.0086", lng: "-0.00056"}
}
alert(myObj['1']['address']); //this get the address value of the first element
//using foreach statement to access the element and key
for (key in myObj){
alert(key); //this will display the 1
//use can say
alert(myObj[key]['address']); // this gets the value of address
}
Groupeshould be object, but is like simple value, no:afterGroup1...