Answer the question
In order to leave comments, you need to log in
How to automatically overwrite JSON?
There is some JSON file file.json. I connect it and change the value of one field:
const file = require('./file.json');
file.text = 'text';
file.text = 'text';
the file itself is automatically overwritten after? Answer the question
In order to leave comments, you need to log in
I don’t know ready-made solutions, but if nothing is found, you can look towards setters (es6), where, after each assignment, call saving the file. In this case, you will have to rewrite the reading process to assign a setter to each read property.
https://developer.mozilla.org/en/docs/Web/JavaScript...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question