I have performed diff of two json files with the output being an array of strings indicating the location within a json tree.
The original json file is something along the lines of:
{
'key': {
'key3': 'value'
},
'key1': {
'key2': 'value2'
}
'key5': {
'key4': 'value4'
}
}
And the output of the diff is:
[
'key.key3',
'key1.key2'
]
I'm able to cycle through all the strings in the array:
(difference).forEach((k) => {
console.log(k);
})
How do I access the value from the original json file using the strings set by the forEach()
function above? I want something like what would be returned if I called originalJSON.key1.key2 directly, but it has to be made up by the strings in the above function.
I've tried originalJSON[k]
but that just returns undefined.