I need help with accessing values from a JSON object based on a key name stored in a variable. My colleague has written a function to extract keys from the JSON object and compare them with the ones we are interested in. However, I am struggling with figuring out how to use the variable containing the key name to retrieve the corresponding values. Although idx holds the member name, it is not a direct member of the object. How can I utilize idx to access obj?
$.each(JSON.parse(data[0][i]), function(idx, obj){
for(var j = 0; j < searchKeys.length; j++){
if (idx == searchKeys[j]) {
//I am unsure how to accurately achieve this
injectLoc.innerHTML += panelMaker(obj.idx, idx, "green", "gears");
}
}
});