Simply Swords [Fabric & Forge]

Simply Swords [Fabric & Forge]

16M Downloads

Config files use JSON5 extension but do not accept valid JSON5

gigawhip opened this issue ยท 1 comments

commented

The config files use the .json5 extension which corresponds to the JSON5 format. One feature of this file format is object keys don't have to be quoted if they are valid identifiers. Example:

// JSON5 only
{ some_key: true }

// JSON, or JSON5
{ "some_key": true }

You can confirm this in an online validator.

If you use this syntax in your config files, the game crashes on startup. I believe you are parsing these files as though they are regular JSON. Shockingly this works even though comments are invalid in regular JSON!

If you want just JSON with comments, use the .jsonc file extension. If you want to keep the .json5 file extension, I recommend finding a proper JSON5 parser for Java. Otherwise when a user edits your config files with a code editor, it may auto-format the files in the conventional JSON5 style, which your current parser does not handle - that's how I found this error!

Another option would be to use .toml files, which are the most common format for Minecraft mod configs. They support JSON-serializable values as well as comments, and have much wider support than .json5 or .jsonc.

commented

Thank you for your suggestion!
I've been sitting on this one for a while, but the latest release has now moved over to using Cloth Config.