I'm attempting to utilize a path variable within a JSON path.
The issue I'm facing is that my variable is being added as a new key to the JSON object instead of replacing the path.
Here's an Example of My Code
Data = {
first:{
"Name":"John",
"Age":"43"
}
}
let path = "first.name"
let value = "Jan"
Data[path] = value
console.log(Data)
Current Result
Data = {
first:{
"Name":"John",
"Age":"43"
},
"first.name": "Jan",
}
Desired Outcome
Data = {
first:{
"Name":"Jan",
"Age":"43"
}
}
Any suggestions on how to resolve this issue? Appreciate your assistance 🙏