Is there a JavaScript implementation similar to HashMap for sorting JSON data in the following scenario?
Here is an example of the JSON structure:
{
"level1": {
"level2": [{
"product1": [
"item1",
"item2"
]
}, {
"product2": [
"item1",
"item2"
]
}, {
"product3": [
"item5",
"item6"
]
}]
}
}
In my use case, when I have a key like 'product3', I need to retrieve its corresponding values such as "item5" and "item6". Although looping through the entire level2 object works, I am wondering if there is a more efficient way to directly find values using the key.