I have an object that looks like this when I do a stringify():
{"key-1":{"inner_key_obj-1":{"A":"1", "AA":"11", "AAA":"111"}, "inner_key_obj-2":{"B":"2", "BB":"22", "BBB":"222"}, "inner_key_obj-3":{"C":"3", "CC":"33", "CCC":"333"}}, "key-2" : "not-an-object-property" }
I'd like to search for and remove they key inner_key_obj-2 so that the object becomes:
{"key-1":{"inner_key_obj-1":{"A":"1", "AA":"11", "AAA":"111"}, "inner_key_obj-3":{"C":"3", "CC":"33", "CCC":"333"}}, "key-2" : "not-an-object-property" }
I know I can use delete to remove a key and its value from an object, but how do I loop thru this to get there?
I did some basic tests such as this:
for (var key in object)
{
if (object.hasOwnProperty(key))
{
//Now, object[key] is the current value
if (object[key] == null)
{
delete object[type];
}
}
}
...but to no avail. Can someone explain how to loop thru this?
inner_key_obj-2only inkey1, or in any object at the higher level?key-1? Or you'd need to search for the object that holdsinner_key_obj-2first?