Looking to retrieve JSON data using 2 state variables. Consider the following JSON object:
{
"user1":
{"age":32,
"role_name":"editor"
},
"user2":
{"age":42,
"role_name":"moderator"
}
}
The variables are as follows:
var1: "user1"
var2: "age"
The desired access format is:
jsonobj.this.state.var1.this.state.var2
Attempted code:
jsonobj.(this.state.var1).(this.state.var2)
jsonobj.{this.state.var1}.{this.state.var2}
Unfortunately, neither of them yielded the desired outcome.