I am stuck on how to parse this JSON using Javascript:
var JSONobj="{
"sec" : {
"username" : "ac12",
"location" : "Indian Ocean",
"online" : true
},
"sec" : {
"username" : "gg66",
"location" : "Pacific Ocean",
"online" : false
},
"sec" : {
"username" : "test123",
"location" : "Atlantic Ocean",
"online" : false
}
}";
var obj = JSON.parse(JSONobj);
I would then like to loop through each "sec" in turn, and extract the username into var UN, eg:
Sec - username = ac12
Sec - username = gg66
etc...
I just can't figure out how to do it.
I would like to use native JavaScript if possible, and not any libraries like jQuery.