I'm trying to use a path variable in a JSON path.
My problem is that my variable is added as a new key to the JSON object instead of replacing my path.
My Example Code
Data = {
first:{
"Name":"John",
"Age":"43"
}
}
let path = "first.name"
let value = "Jan"
Data[path] = value
console.log(Data)
Current Output
Data = {
first:{
"Name":"John",
"Age":"43"
},
"first.name": "Jan",
}
Expected Output
Data = {
first:{
"Name":"Jan",
"Age":"43"
}
}
Is there a way to solve this? Thanks for your help