Skip to content

Support HJSON - #140

Open
westonganger wants to merge 2 commits into
locomotivecms:masterfrom
westonganger:hjson_support
Open

Support HJSON#140
westonganger wants to merge 2 commits into
locomotivecms:masterfrom
westonganger:hjson_support

Conversation

@westonganger

Copy link
Copy Markdown
Contributor

As described in locomotivecms/engine#1321

Website: https://hjson.org/
Ruby gem: https://github.com/hjson/hjson-rb

HJSON adds the following features to JSON:

  • Trailing Commas
  • Comments (#, //, /* */)
  • Quoteless Keys
  • Quoteless String (meh but okay why not)
  • Write multiline strings with proper whitespace handling.

@did

did commented Jun 22, 2019

Copy link
Copy Markdown
Member

hey @westonganger, I wasn't aware of this gem! Looks awesome but the ruby implementation doesn't have a good SyntaxError exception in the sense that it doesn't report the line number where the error occurs.
I know that hjson is highly permissive so it might look minor but I believe it's important.
I don't mention that other developers would stick to the old JSON format.

Why not enabling hjson per Wagon site? What are your thoughts? Have you already built sites with this syntax?

@westonganger

Copy link
Copy Markdown
Contributor Author

Sure we could enable it per project. Maybe we add this key within config/site.yml

### For more permissive JSON syntax we can use HJSON, https://hjson.org/
### when set to true, the `hjson` gem must be included within your Gemfile
hjson: false

@westonganger

westonganger commented Jun 23, 2019

Copy link
Copy Markdown
Contributor Author

Also I may try to see if we can add line number reporting to the HJSON gem.

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

Successfully merging this pull request may close these issues.

2 participants