-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support JSON5 deserialization #160
Conversation
JSON5 is a superset of JSON, which includes support for trailing commas, extra whitespaces, comments, and an expanded set of numbers. This commit adds mainly decoding support for json5, in `@lune/serde`. Encoding "support" is also included, but isn't a practical use-case. * Expanded `EncodeDecodeFormat` to have a `Json5` variant * Handled JSON5 decoding using `serde_json5` crate * Matched JSON5 encoding alongside JSON
It seems this PR conflates two different standards (json and json5) in a couple places. In previous discussion on Discord I also rejected the proposal to add json5, with the two main points being:
A better option here would be "json with comments", using something like https://crates.io/crates/jsonc-parser. This is human-friendly JSON that doesn't try to include lots of extra ECMAScript syntax. |
Could you elaborate? JSON is technically valid JSON5, and so encoding is the only place I've used them interchangeably. |
Also, if you could reopen the PR, I guess I could replace the existing changes to make use of JSONC instead, considering the changes were seemingly trivial. |
For
I would like to keep this one closed so that it is searchable/linkable in the future, but feel free to make another PR |
Thanks for the clarification, guess I'll create a new PR in the future once I've finished the ones I'm currently working on. |
This PR implements JSON5 deserialization (and serialization too, for the sake of completeness) for the
serde
andnet
builtin libraries.TODO:
@lune/serde
encode
decode
@lune/net
jsonDecode
json5
union variantCloses #141.