I have a JSON object of the following type:
{
ONE:
{ id: 7,
first: '0.000001',
last: '0.00000017'},
TWO:
{ id: 8,
first: '0.000002',
last: '0.00000027'},
THREE:
{ id: 9,
first: '0.000003',
last: '0.00000037'},
FOUR:
{ id: 10,
first: '0.000004',
last: '0.00000047'}
}
And I'm looking to search for the right name (ONE for example) and use that object. I've tried using hasOwnProperty('ONE')
and found the actual property, but I don't understand how to access the data within it. Keep in mind, I'm getting 'ONE'
from a variable, so I couldn't just do something like this:
var property='ONE'
var temp = JSON.parse(obj)
console.log(temp.property.id)
console.log(temp.property.first)
console.log(temp.property.last)
How can I "dynamically" find the property im looking for and access the data within it?