Say I have this code in node.js:
var fs = require("fs");
var file_content = fs.readFileSync('file.json');
var json = JSON.parse(file_content);
let x = "c";
json.x = 3;
fs.writeFileSync("file.json", JSON.stringify(json));
and this JSON file:
{"a":1,"b":2}
I want to create json object "c"
but this code would create "x"
. How would I create "c"
this way?