Answer the question
In order to leave comments, you need to log in
How to record data correctly?
How to write data correctly
I write
fs.appendFile('./data.txt', JSON.stringify(data));
And so several times, as a result I have several arrays in the date file,
then I want to get them
data = JSON.parse (result)
as a result I get
}, {
"update": "11:09"
}][{
"update": "Сегодня, 21:45"
}, {
Answer the question
In order to leave comments, you need to log in
Like a crutch, but in most cases it will work:
You can also do this:
data = JSON.parse(result.replace(/\]\[/g,'],['));
data = JSON.parse(result.split('][').join('],['));
appendFile()
suitable for simple text files, such as logs.
In the case of JSON, you need:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question