Section 20
This commit is contained in:
11
playground/1-json.js
Normal file
11
playground/1-json.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const dataBuffer = fs.readFileSync('1-json.json');
|
||||
const dataJSON = dataBuffer.toString();
|
||||
const data = JSON.parse(dataJSON);
|
||||
|
||||
data.name = 'Jason';
|
||||
data.age = 38;
|
||||
|
||||
const newJSON = JSON.stringify(data);
|
||||
fs.writeFileSync('1-json.json', newJSON);
|
||||
1
playground/1-json.json
Normal file
1
playground/1-json.json
Normal file
@@ -0,0 +1 @@
|
||||
{"name":"Jason","planet":"Earth","age":38}
|
||||
Reference in New Issue
Block a user