I have this JSON data stored in variable result
, now I want to access the value of result.metadata.data.s1[1].lily
, however the key Lily
is not known and it may change on server side, so I stored the key as a variable, like var key1 = "Lily"
. How to access the value with this var key1
?
{
"metadata":{
"data":{
"s1":[
{
"Lily":"chat",
"time":10
},
{
"Mancy":"chat1",
"time":10
},
{
"John":"chat2",
"time":10
}
],
"s2":[
{
"Lan":"chat3",
"time":10
},
{
"Yoyo":"chat6",
"time":10
}
]
}
}
}