I have a JSON file, I need to read that JSON file and update a particular key with new values. How can I do it with the help of javascript in the typescript file?
datafile.json:
{
   "Id": {
       "place": {
           "operations": [{
               "Name": "John",
               "Address": "USA"
           }]
       }
   }
}
Now in my test.ts file
const filepath = 'c:/datafile.json';
var testjson = filepath.Id[place][operations][0];
var mykey = 'Address';
//testjson[mykey] = 'UK';
updateJsonFile(filepath, (data) => {
  data[mykey] = 'UK';
  console.log(data);
  return data;
});
The issue is it update the JSON with new key and values as below:
{
    "Id": {
        "place": {
            "operations": [{
                "Name": "John",
                "Address": "USA"
            }]
        }
        "Address": "UK"
    }
}
But I want to just change the value of a particular key then adding new keys. Is it possible in JS.?
 
    