I will be getting a dynamic json as response, so I am using the below to get the key names and I always want the third key value which will either be true or false. So i get the third key's value using the below which is stored inside the theTypeIs and when I try to access the json I get undefined
example Json
submitResult = [{
ComodityID: 33,
ComodityName: 'LED',
field1: true
}, {
ComodityID: 342,
ComodityName: 'Installing ',
field1: true
}, {
ComodityID: 322,
ComodityName: ' Bracket',
field1: true
}
]
To find the third key name in the dynamic json:
var theTypeIs = Object.keys(submitResult[i])[2];
console.log(submitResult[i].theTypeIs)
I get undefined when i console log it. Can someone help me on this. Thank you in advance.