-
-
Notifications
You must be signed in to change notification settings - Fork 55
Backup playerlist in event of malformed json #235
Comments
I think the priority for this should be high too |
I think this is somewhat intended behavior. In the event of a malformed json input it will overwrite the offending file following the json scheme. In general it is strongly recommended to backup files you are modifying and also to use a linter when working with json. Some provision to prevent this could be baked in but I am not sure how valuable that would be when users can do it so effortlessly. |
No, this is a wrong. A valid JSON is allowed to have a , at the last item and currently having so deletes the whole JSON. The current ruling that causes the problem is validated by JSON linters |
I'm sorry, upon studying the issue it seems i was in the wrong here. JSON doesnt actually allow trailing commas but parsers often fix that silently. I still think it would be good to have anyways |
After trying 3 different linters, they all agree. That is an EOF error. I am fairly certain that valid json does not end in a comma. edit: this was sent at the same time as the above message |
Indeed, the linter I was using was fixing it for me https://jsonformatter.curiousconcept.com/ |
Hey there, sorry about that. It is indeed intended behavior that it overwrites config files if it is unable to parse them, and replace them with the default config. There was code in there to make a backup of the file, but that only applied to settings.json. Trailing comma support is unlikely, since unfortunately the author of the json library I am using has a fairly extreme (and in my opinion unhelpful) stance on adding stuff that isn't in the json spec nlohmann/json#376. I already need to take a look at the config file code to address some other robustness issues, so I'll see if I can add support for making backup files for anything that gets overwritten at the same time. |
Describe the bug
To Reproduce
Expected behavior
Logs
Screenshots
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: