- Go 88.7%
- Shell 11.3%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .agents-sync.jsonc | ||
| .gitignore | ||
| AGENTS.md | ||
| build.sh | ||
| CLAUDE.md | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| main_test.go | ||
| README.md | ||
| THIRD_PARTY_LICENSES.txt | ||
jsonc-to-json
Converts JSONC (JSON with // and /* */ comments and trailing commas) to
strict JSON, so tools like jq can parse it. Ships as a single static binary
with no runtime dependencies.
Usage
jsonc-to-json [-c] [file|-]
Reads from file, or stdin if no file (or -) is given, and writes JSON to
stdout.
jsonc-to-json settings.json | jq .
cat settings.json | jsonc-to-json -c | jq 'del(.ssh_connections)'
-
-ccompacts the output. Without it, the original layout is kept and comments are replaced with spaces. -
Output is validated as strict JSON before anything is written. Invalid input writes nothing to stdout, prints an error with the line and column to stderr, and exits nonzero:
jsonc-to-json: settings.json:3:3: invalid character '"' after object key:value pair
Exit codes: 0 success, 1 conversion or I/O error, 2 usage error.
Build
Requires Go 1.20 or newer.
./build.sh # writes to ./dist
./build.sh ./release # or a directory of your choice
This builds static (CGO_ENABLED=0) binaries for darwin and linux on
amd64 and arm64, named jsonc-to-json-<os>-<arch>.
Run the tests with go test ./....
License
MIT; see LICENSE. JSONC parsing is provided by
github.com/tidwall/jsonc, also MIT;
see THIRD_PARTY_LICENSES.txt.