I have a json object and a property of which is a nested json. The nested json has a function as a property. I want to access a property in that outer json from that function in that inner json.
Let me explain with a dummy code,
{
name: "Barry Allen",
getName: function () {
return this.name; //this is returning "Barry Allen", which is fine
},
nestedJson: {
getName: function () {
//here I want something like return this.parent.name
}
}
}
I want to access name
from getName
of nestedJson
. Is it possible? Is there any parent child traversing mechanism/way in json and nested json objects in javascript?
Thanks in advance.