Answer the question
In order to leave comments, you need to log in
How to append data to JSON in NODE.JS?
Tell me how you can implement padding (at the end of the file) in .json in node.js so that this padding is carried out between the characters '{' and '}'
Like this:
Answer the question
In order to leave comments, you need to log in
And why not do this: get data from a file, make an object, add the necessary properties to it, convert it back to a string, write it to a file?
Two options
First
Solution in the forehead as suggested here. We read the file as a whole, add a new element to json and write (resource-intensive garbage and file size limit to 1 Gbit)
The second option is to read the file bit by bit in a separate stream, find out the position of the last bracket and add our characters there
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question