See JSON5 capabilities from https://github.com/Joakker/lua-json5?tab=readme-ov-file#so-why-should-i-use-this-instead-of-the-builtin-json_decode:
The advantage this package has over regular json, however, is that you get json5 features, such as comments, trailing commas and more flexible string literals.
So basically JSON5 added capabilities/syntax:
- comments
- trailing commas
- more flexible string literals (don't know what it means)
This package have a support for 1 via the function json_strip_comments()
, but doesn't have a support for removing trailing commas, even though it seems that all the complex code is there, and with a little extra effort we can have a reg expression or such that detects the patterns ,(whitespace)}
and ,(whitespace)]
easily.
Not sure about 3, what it means and if we want it.
Basically, the nice function we could have is a transformer from JSON5 to JSON.