How to replace a line in save file (json)?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By anssiko


I’m using json dictionary to store save data. In general I use READ and WRITE to save or load several characters: Each line has keys of character stats.

Now I’m trying to upgrade stats one by one directly to and from the save file without loading the character nodes. I can use READ_WRITE to find a specific value and change it, but if I use store_line I only get new lines at the end of the save file.

How to replace a specific line in json file?

Bonus question: is json actually a good choice for saving game data for a relatively simple single-player game?

:bust_in_silhouette: Reply From: njamster

Consider using a ConfigFile instead. With JSON, you’d need to re-write the entire save-file even if you only changed one line.