Do you consider supporting json5 / hjson? Or is there any fast program that convert them to plain json?
@ololoe - Please see the jq FAQ about hjson and similar utilities.
As best I can tell, there is no momentum towards supporting json5 or hjson, but there is perhaps some hope that jq will be able to ignore the type of comments that you see in "raw" gists such as
json5 on your link is using nodejs, I think it will be slower or at least start slower than C(++) program. Is there a reason why jq does not extend its parser for at least comments?
See https://github.com/stedolan/jq/issues/1571 regarding jq's support for comments. (The historically minded might also be interested in https://github.com/stedolan/jq/issues/402 .)
It seems to me that there have been three main stumbling blocks in the way of jq allowing comments:
a) There are many ways of commenting JSON, and there seems to be no way to make everyone happy;
b) jq aims to be very lightweight;
c) There have been (and arguably continue to be) higher-priority items for jq.
In my opinion, though, the time is ripe for a minimalist enhancement that would permit jq to ignore the '//' comments that often appear as the first few lines of a file. This convention is in widespread use (e.g. gist; datasette) and it would be very helpful if jq understood it; it would not require much effort to implement; and it would not preclude future enhancements in the same direction.
a) Use ECMA-compatible comments.
b) Comment skipping is a very minor change to the parser
I would accept if there would be a converter from json5 / hjson that would be as fast as jq.
Surely it would be better to use jq itself to filter out the comments etc, e.g. to condition a rawfile input into pure JSON.
That way all the complexity of converting from non-pure-JSON formats to pure JSON could be kept out of the jq core and moved out to input filter library scripts that are simply jq code.
e.g. --filterfile mydata mydata.json json5.jq
Here json5.jq would be an external library script written in jq that would read in data as a --rawfile and output it as pure JSON.
Most helpful comment
Surely it would be better to use jq itself to filter out the comments etc, e.g. to condition a rawfile input into pure JSON.
That way all the complexity of converting from non-pure-JSON formats to pure JSON could be kept out of the jq core and moved out to input filter library scripts that are simply jq code.
e.g. --filterfile mydata mydata.json json5.jq
Here json5.jq would be an external library script written in jq that would read in data as a --rawfile and output it as pure JSON.