“Отредактируйте файл json в Nodejs” Ответ

Изменить JSON через 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

написать json file nodejs

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

Отредактируйте файл json в Nodejs

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

const ciqlJson = require("ciql-json")

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

Ответы похожие на “Отредактируйте файл json в Nodejs”

Вопросы похожие на “Отредактируйте файл json в Nodejs”

Больше похожих ответов на “Отредактируйте файл json в Nodejs” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования