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

Support for Jsonc (.json files with comments) #106

Open
Eonfge opened this issue Sep 6, 2020 · 3 comments
Open

Support for Jsonc (.json files with comments) #106

Eonfge opened this issue Sep 6, 2020 · 3 comments
Labels

Comments

@Eonfge
Copy link
Contributor

Eonfge commented Sep 6, 2020

Jsonc is a simplified json format which allows comments and unquoted values delimited by whitespace. A jsonc formatted file can be transformed to a json file. Comments will be stripped out and quotes added.

https://komkom.github.io/

Right now, parsing json files with comments, causes it to fail. This is annoying since comments are an all-round good practice and they are often de facto required when working in teams.

@Eonfge Eonfge changed the title Support for .jsonc Support for Jsonc (.json files with comments) Sep 6, 2020
@zoeyfyi
Copy link
Owner

zoeyfyi commented Sep 6, 2020

Definitely would be nice to have, I always use JSON parsers that accept comments in my projects.

The scripts are quite easy to generate, for example here is a "format jsonc" script that you can drop into Boop-GTK's scripts folder. This was generated with the following:

const jsonc = require('jsonc-parser');

global.main = function (state) {
   let edits = jsonc.format(state.text, undefined, { tabSize: 4, insertSpaces: true, eol: "\n" });
   state.text = jsonc.applyEdits(state.text, edits);
}

Then following the instructions here.

As far as including it in the default set of scripts, right now all the scripts come from the project this was based of, Boop. I am not sure what the best policy for script requests should be, but perhaps its best to open an issue in the Boop repo, then both projects can benefit.

@Eonfge
Copy link
Contributor Author

Eonfge commented Sep 7, 2020

I've reported it upstream. You want to keep this issue open or is this good enough for now?

@zoeyfyi
Copy link
Owner

zoeyfyi commented Sep 7, 2020

May as well keep it open.

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

No branches or pull requests

2 participants