zoeyfyi / Boop-GTK

Port of @IvanMathy's Boop to GTK, a scriptable scratchpad for developers.

Home Page:https://boop-gtk.zoey.fyi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for Jsonc (.json files with comments)

Eonfge opened this issue · comments

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.

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.

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

May as well keep it open.