Giter VIP home page Giter VIP logo

Comments (9)

Conaclos avatar Conaclos commented on June 10, 2024 2

This chart on NPM shows an higher use of JSON5 parser:
https://npmtrends.com/hjson-vs-json5-vs-jsonc-parser-vs-relaxed-json

It is really easy to support JSONC in an existing JSON parser, because all you have to do is comments and trailing comma handling. So it is not surprising that few people use the jsonc parser directly. I was not aware of its existence.

How do you measure the popularity of JSON5 vs JSONC?

Mostly of experience.
Most of the configurations I am aware of use JSONC (tsconfig.json, vscode configurations, ...).

If I search for all files using jsonc on GitHub extension I found 32k files. However, this doesn't take JSONC files using .json extensions such as tsconfig.json (930k files), vscode configs (31k files), and so on.
With a pessimistic measure we are already to more than 1M files using JSONC on GitHub.

33k files use the JSON5 extension.

Chromium uses JSON5 for internal configs

If I remember correctly, the creator of JSON5 is from Google? That's not surprising that some of their project use JSON5.

from biome.

lgarron avatar lgarron commented on June 10, 2024 2

I'd also like to put in a word for supporting JSON5 and ideally recommending it over JSONC if you have a choice between the two. There are a few good reasons mentioned in microsoft/vscode#100688 (comment) but the main one is:

There is no standard of JSONC, just conventions. However, JSON5 is a format with spec.

JSONC is a bit of a liability as a result: feature set/compatibility/conformance/security/etc.

Since JSONC support is new for Biome, it's possible to make a more future-proof choice.

from biome.

ematipico avatar ematipico commented on June 10, 2024 1

@giacomorebonato

If you're interested, you can try creating a parser using our infrastructure, and we can evaluate its inclusion.

JSON5 is outside our roadmap and interests, so I don't think we have the capacity to help you.

from biome.

giacomorebonato avatar giacomorebonato commented on June 10, 2024

The terse syntax of biome.json5 would be nice as well.
.jsonc is also great anyway, thanks!

from biome.

ematipico avatar ematipico commented on June 10, 2024

The terse syntax of biome.json5 would be nice as well.
.jsonc is also great anyway, thanks!

Unfortunately Biome doesn't support the json5 file extensios. Do you know if they have differences in their grammar?

from biome.

Conaclos avatar Conaclos commented on June 10, 2024

There are many differences. For example JSON5 allows unquoted properties, single quoted strings, hexadecimal numbers, NaN, Infinity constants, ...

There are many competing standards out there to make JSON more convenient: JSON5, JSON6, HJSON. They don't seem to be as widespread as JSONC.

from biome.

giacomorebonato avatar giacomorebonato commented on June 10, 2024

How do you measure the popularity of JSON5 vs JSONC?

This chart on NPM shows an higher use of JSON5 parser:
https://npmtrends.com/hjson-vs-json5-vs-jsonc-parser-vs-relaxed-json

Also:

Chromium uses JSON5 for internal configs, e.g. runtime_enabled_features.json5.
Craft elaborately sequenced animation timelines using ProStyle. Write your stories in a declarative JSON5 syntax and ProStyle will generate the web content and scripts that animate it. (examples)
A web-based JSON-to-CSV converter. The application is open source, and conversion is performed in the browser and data is never uploaded to a server.
WebStorm natively supports JSON5.

Taken from https://github.com/json5/json5/wiki/In-The-Wild#apps

Since both JSONC and JSON5 have valid JS syntax, hence Biome knows it, I wish they could be both supported.

from biome.

Eutropios avatar Eutropios commented on June 10, 2024

Came here looking for this issue before opening one of my own.

I'd imagine that implementing a linter/formatter for JSONC (json w/ comments) would be significantly easier than an implementation for JSON5, JSON6, and HJSON due to the numerous additions in each format. I'd also imagine that extending this further to YAML 1.2 (a strict-superset of JSON) and Google's DSL jsonnet would be out of scope for this project.

I'm unsure if this could be of any help to whomever implements this parser, but the neovim implementation of treesitter has a parser for JSONC which can be found here. It also has parsers for JSON5, HJSON, jsonnet, and YAML.

Looking forward to what this project has in store for the future. Keep up the good work!

from biome.

Malix-off avatar Malix-off commented on June 10, 2024

Same recommendation for me : json5 > jsonc

from biome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.