I have the following JSON format:
Object {person: Array[10]}
I want to get the name called person.
I don't want to get the inner content just I want the name called person
to store it in a variable.
How can I achieve this?
According to MDN you can do this like this, assuming your object is stored in a variable named obj:
var keys = Object.keys(obj);
var person = keys[0];
Or another approach:
for ( prop in obj ) {
// prop is the key name.
}
personhere is a "key".