Let's say, I have the following JSON, which can be easily converted back and forth to a JavaScript object:
{
    "foo": {
        "bar": "Common substitute word",
        "baz": "Another common substitute word",
        "questionWords": {
            "wat": "Inadequate question word",
            "wut": "Even more inadequate question word"
        }
    }
}
And I receive modifications regarding this JSON in another JSON file, like this:
{
    "foo.questionWords.wut": "A question word to avoid"
}
So the path to modify is given as a string. And I have to modify the first JSON by the new data.
But also the new data path possibly does not exist:
{
    "foo.callingWords.dude": "Commonly used synonym for pal"
}
And the new data path might have indeterminable depth:
{
    "who.knows.how.deep.we.will.go": "Look, a penny!"
}
What is the best way to handle this without a JS library, just by plain Vanilia JS?
(You can use the latest JavaScript features.)
Thank you for your help!
 
     
    
 
     
     
    