Feb 24, 2020 at 2:54pm UTC
I'm trying to write a program that edits this .json in a noob-friendly way. I need it to put lines in between lines. What is the easiest way to do this?
Feb 24, 2020 at 2:59pm UTC
You copy the file, line by line, and when you get to the place where you want you new line, you write it. Then you keep copying.
Feb 24, 2020 at 3:27pm UTC
That, or simply load the file into memory, insert the line, and write the file back out.
Have you considered using a JSON library to help you out?
Feb 24, 2020 at 4:05pm UTC
You open the file that you want to read from, and you open a file to write to.
You read a line from the input file, using a function such as getline. Then you write it out to the output file.