“Edit file JSON di NodeJS” Kode Jawaban

Edit JSON via NodeJS

//Using edit-json-file for NodeJS, based off the NPM documentation for edit-file-json
const editJsonFile = require("edit-json-file");
let file = editJsonFile(`${__dirname}/filename.json`);
file.set("name", "value");
file.save();
file = editJsonFile(`${__dirname}/filename.json`, {
    autosave: true
});
k3rsh0k

Tulis NodeJs File JSON

const fs = require('fs');
const path = require('path');

let student = { 
    name: 'Mike',
    age: 23, 
    gender: 'Male',
    department: 'English',
    car: 'Honda' 
};
 
fs.writeFileSync(path.resolve(__dirname, 'student.json'), JSON.stringify(student));
Victor Grk

Edit file JSON di NodeJS

//inistall ciql-json : npm i ciql-json

const ciqlJson = require("ciql-json")

ciqlJson
    .open("file.json")
    .set("address", {town : "", city : ""})
    .save()
Light Lark

Jawaban yang mirip dengan “Edit file JSON di NodeJS”

Pertanyaan yang mirip dengan “Edit file JSON di NodeJS”

Lebih banyak jawaban terkait untuk “Edit file JSON di NodeJS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya