My object looks like this
{
"about.php": [
"#topNav",
"#botNav",
"#employees"
],
"index.php": [
"#blah"
]
}
I am looping through it like so
var validation_messages = obj;
for (var key in validation_messages) {
if (validation_messages.hasOwnProperty(key)) {
var obj = validation_messages[key];
for (var prop in obj) {
if(obj.hasOwnProperty(prop)){
console.log(prop + " = " + obj[prop]);
}
}
}
}
I am getting this result
0 = #topNav
1 = #botNav
2 = #employees
0 = #blah
I need the name of the object key not the key of the array that is in the objects value. like so:
about.php = #topNav
about.php = #botNav
about.php = #employees
index.php = #blah
I will be pushing new values into the arrays if they do not exists like so:
{
"about.php": [
"#topNav",
"#botNav",
"#employees"
],
"index.php": [
"#blah",
"#newValue"
]
}