R
R
Richard Hendrix2017-09-24 04:13:29
JSON
Richard Hendrix, 2017-09-24 04:13:29

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:
62abeb3b1ccc423d9c7fffdf36b23701.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
0
0xD34F, 2017-09-24
@0xD34F

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?

A
Alexander Sisyukin, 2017-09-24
@Caarl

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 question

Ask a Question

731 491 924 answers to any question