bazelbuild / bazelbuild/bazel

Support JSONC in json module

Open
#24,859 4 comments 4 reactions 0 assignees View on GitHub
P4 team-Loading-API type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 18h
Merged PRs (30d)
75

Description

### Description of the feature request:

It would be great to support [JSONC](https://code.visualstudio.com/docs/languages/json#_json-with-comments) format in json module.

```starlark
json.decode(str, allow_comments = True)
```

or

```starlark
jsonc.decode(str)
```

### What underlying problem are you trying to solve with this feature?

With the adoption of bzlmod, and https://github.com/bazelbuild/bazel/issues/14632. Maintaining all the extension configs in MODULE.bazel becomes harder and harder.

Therefore, as a rule author, I'd love to provide a way for users to offload such configs in a separate file. And most importantly I want this file to be somewhat ergonomic to work with. For now, the only natively supported data format is JSON. However, JSON is not a great format for human maintained data, where comments and trailing commas are appreciated. On the other hand, JSONC solves those issues perfectly while not introducing lots of complexity to the parser.

### Which operating system are you running Bazel on?

macOS

### What is the output of `bazel info release`?

6.2.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.

_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?

_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating Bazel's json module and its existing decode entry point. Compare the requested allow_comments parameter with the alternative jsonc.decode API, then identify the relevant tests and define done as accepting JSONC comments and trailing commas without regressing standard JSON behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.