Skip to content

native JSONC parsing #12402

Open
Open
@aster-void

Description

Is your feature request related to a problem

nix can't natively parse JSONC.

more specifically, I had to manually remove trailing commas from bun.lock to parse it into nix object.

Proposed solution

add builtin function builtins.fromJSONC

JSONC doesn't have "one universal standard", but it's generally assumed to be JSON superset with C-style comments (// and /* */) and trailing commas allowed (but not required)

Alternative solutions

  1. add support for JSON5, which is superset of JSONC and has a universal standard https://json5.org/
  2. use some package from nixpkgs to parse it (IFD)
  3. manually remove comments and trailing commas from JSONC to then parse with builtins.fromJSON

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    featureFeature request or proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions