Skip to content
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

How does this compare to json5? #48

Open
TheKnarf opened this issue Nov 20, 2019 · 3 comments
Open

How does this compare to json5? #48

TheKnarf opened this issue Nov 20, 2019 · 3 comments

Comments

@TheKnarf
Copy link

TheKnarf commented Nov 20, 2019

How does this compare to json5? Would be nice if the readme at least mentioned whats different between the two.

@vwbusguy
Copy link

vwbusguy commented Feb 24, 2020

The things that I can see that are most obvious is that json5 requires comma delimiting (though trailing commas are OK) and quoting of strings as a value (keys do not need quoted), but json5 also supports in-line comments.

@lewisl9029
Copy link

I've been researching config formats lately, and so far hjson is the front-runner for supporting comment-preserving edits in its node implementation. Haven't found anything else yet that satisfies this requirement in a node implementation. Kudos to the hjson team for prioritizing this awesome feature!

@dqsully
Copy link
Member

dqsully commented Jan 31, 2022

JSON5 is a project to use ES5-like syntax for config files, and it's mainly tailored to a JavaScript implementation last I checked. Hjson is a similar format designed to be more a more human-friendly version of JSON, and has libraries across many different languages. They are indeed very similar - they are both supersets of JSON that try to improve the UX, but take slightly different and incompatible approaches.

Compared to JSON5, in Hjson commas are optional at the ends of lines, quoteless object keys are more flexible, and quoteless string values are a thing (although they are slightly different than YAML's quoteless strings). However, Hjson does not natively support hex, octal, or binary numbers, NaNs, infinities, or leading plusses like JSON5 does.

The JavaScript implementation of Hjson is the main one, and it supports node-based comment editing like @lewisl9029 mentioned in trying to satisfy the concept of a config file as human-machine interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants