Answer the question
In order to leave comments, you need to log in
How to create a JSON entry?
Is it possible to make it so that after entering the command a new entry is created in the JSON file?
Answer the question
In order to leave comments, you need to log in
Oh sure.
for example:
let test = []; //object, mutable.
test.push({ //adding a new array.
//native code
});
console.log(test) //output.
Let's create a json file in the folder with the code and connect it to it. in json file [].
after that we will autosave this json every 1.5 seconds. connect fs module
const tasks = require('./tasks.json'); // массив
const fs = require('fs'); // модуль fs
setInterval(async() => {
fs.writeFileSync("./tasks.json", JSON.stringify(tasks, null, "\t"));
}, 1500); // "автосохранение" tasks.json
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question