I have a JSON structure that looks like this:
{
map: [
{"key1":"valueA1", "key2":"valueA2", "key3":"valueA3"},
{"key1":"valueB1", "key2":"valueB2", "key3":"valueB3"},
{"key1":"valueC1", "key2":"valueC2", "key3":"valueC3"},
.... and so on
]
}
When I load this into my JavaScript application using JSON.parse(), I want to be able to retrieve the value of key3 from the object in the array where key2='valueB2'.
I currently achieve this by looping through the array, but I'm wondering if there is a more elegant and efficient way to do this without knowing the index number of the array element.
I've searched extensively online for solutions, but with little success. Would it be better for me to simplify or remove the array altogether and use a list of objects instead?
Thank you!