-2
//filejson.json
{
"body":
  {
   "name":"abc"
   }
}

//mainFile.js
var readJson = require("/filejson.json")
var req=clone(readJson.body);

I want to change the name of JSON value without changing .json file. I need to set name value using rewire module. Can you help me how to set key value pair dynamically. Is it possible to set like this. Please help me Thanks in advance.

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143

1 Answers1

1
var readJson = require("/filejson.json")
readJson.name = "defg";

Require just use the file, no changes will occur to the file.

Ido
  • 2,034
  • 1
  • 17
  • 16