Hi I have a json string
"{"data":[{"Id":14,"ConfigName":"Online Hrs","ConfigValue":"00:01-23:59"},{"Id":15,"ConfigName":"Offline Days","ConfigValue":"Sunday"},{"Id":0,"ConfigName":"CurrentTime","ConfigValue":"11:3"}]}"
I want to check ConfigValue
of ConfigName
"CurrentTime".
Currently I am accessing it by below code
var d = JSON.parse(data).data;
d[2].ConfigValue
but sometimes the json string will be
"{"data":[{"Id":14,"ConfigName":"Online Hrs","ConfigValue":"00:01-23:59"},{"Id":0,"ConfigName":"CurrentTime","ConfigValue":"11:3"}]}"
according to above string now if i want to access "CurrentTime"
I will have to write below code
var d = JSON.parse(data).data;
d[1].ConfigValue
So can anyone tell how to access it? Because the array may change anytime so I cannot hardcode the array index like that.