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

[RFC] Add API for parsing JSONC #16257

Open
DonIsaac opened this issue Jan 8, 2025 · 0 comments
Open

[RFC] Add API for parsing JSONC #16257

DonIsaac opened this issue Jan 8, 2025 · 0 comments
Labels
enhancement New feature or request runtime

Comments

@DonIsaac
Copy link
Contributor

DonIsaac commented Jan 8, 2025

What is the problem this feature would solve?

We've improved several APIs to handle JSONC out of the box.

  • package.json files may have comments and trailing commas
  • console.log({ ... }) prints trailing commas

These are good user experiences, but dynamically reading data formatted this way is currently difficult (e.g. using Glob to walk a directory and read all package.json files). JSON.parse does not support it in order to maintain spec compliance, so users need to install a third-party library.

What is the feature you are proposing to solve the problem?

Add an API to parse JSONC natively.

I'm currently thinking something like Bun.json.parse(obj), but would love input on API design.
Ideally the API would

  • look and act in a familiar way to JSON.parse, but with non spec-compliant niceties for better DX
  • Be namespaced so we can add more stuff in the future
@DonIsaac DonIsaac added enhancement New feature or request runtime labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request runtime
Projects
None yet
Development

No branches or pull requests

1 participant