Hujson grammar for tree-sitter
Project description
tree-sitter-hujson
A tree-sitter grammar for HuJSON (Human JSON), also known as JWCC (JSON With Commas and Comments).
HuJSON is a strict superset of JSON that adds exactly two features:
- C-style comments: line comments (
//) and block comments (/* */) - Trailing commas: an optional trailing comma after the last element in arrays and objects
All valid JSON is valid HuJSON. HuJSON intentionally rejects every other extension (unquoted keys, hex literals, Infinity/NaN, single-quoted strings, and so on); object keys must be quoted strings, exactly as in standard JSON.
The grammar registers both the .hujson and .jwcc file extensions.
Installation
The grammar is published to npm, PyPI, and crates.io. Each package exposes the compiled language for use with that ecosystem's tree-sitter bindings.
Each example needs the tree-sitter runtime for that language alongside this grammar.
npm (Node.js)
npm install tree-sitter tree-sitter-hujson
const Parser = require("tree-sitter");
const HuJSON = require("tree-sitter-hujson");
const parser = new Parser();
parser.setLanguage(HuJSON);
PyPI (Python)
pip install "tree-sitter-hujson[core]"
import tree_sitter_hujson
from tree_sitter import Language, Parser
parser = Parser(Language(tree_sitter_hujson.language()))
crates.io (Rust)
cargo add tree-sitter tree-sitter-hujson
let mut parser = tree_sitter::Parser::new();
parser
.set_language(&tree_sitter_hujson::language())
.expect("loading HuJSON grammar");
Go, Swift, and C
These bindings ship in the repository and are consumed directly from the tagged source rather than a package registry.
Editor support
- Zed: install the
ggfevans/zed-hujsonextension. This is the only editor integration maintained and tested here. - Other tree-sitter hosts (for example Neovim via nvim-treesitter, or Helix): this is a standard tree-sitter grammar and can be registered through each host's normal grammar mechanism.
Markdown code blocks fenced as ```hujson are highlighted in editors that resolve fence languages by name (verified in Zed). This works through the declared language scope and name; it needs no injections.scm on the grammar side, because the host Markdown grammar supplies the injection.
Provenance
Forked from tree-sitter/tree-sitter-json at commit 001c28d. The upstream grammar already supported comments, so HuJSON support needed only two changes:
-
Trailing commas. The
commaSephelper now allows an optional trailing comma:function commaSep1(rule) { return seq(rule, repeat(seq(",", rule)), optional(",")); }
-
String-only object keys. Upstream tree-sitter-json accepts numeric object keys (
choice($.string, $.number)); HuJSON restricts keys to strings to match standard JSON, so bare numeric keys are parse errors. This tightened in v0.2.0.
Contributing
See CONTRIBUTING.md for development setup, the test suite, and the release process.
Licence
MIT, matching the upstream tree-sitter-json licence.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tree_sitter_hujson-1.0.1.tar.gz.
File metadata
- Download URL: tree_sitter_hujson-1.0.1.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5abed1ea8b1a695ff6f3a2c82a5d715e7b0cd2b7af094c56ae5a38ba65264edf
|
|
| MD5 |
48a8a19d376cd420d904f07b30ca6bbc
|
|
| BLAKE2b-256 |
a66ece6bf61342478f0206320777b1a57fe656393435152bb7d6f280c1724060
|
Provenance
The following attestation bundles were made for tree_sitter_hujson-1.0.1.tar.gz:
Publisher:
release.yml on ggfevans/tree-sitter-hujson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_hujson-1.0.1.tar.gz -
Subject digest:
5abed1ea8b1a695ff6f3a2c82a5d715e7b0cd2b7af094c56ae5a38ba65264edf - Sigstore transparency entry: 1708812543
- Sigstore integration time:
-
Permalink:
ggfevans/tree-sitter-hujson@506ab946025772028c0050d8c6b555ef5670f4b5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfevans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@506ab946025772028c0050d8c6b555ef5670f4b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_hujson-1.0.1-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: tree_sitter_hujson-1.0.1-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 13.1 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3e659931440eeb6f6b44e8bf8f137de6d2039e6ab365d53182da43368d4ba3c
|
|
| MD5 |
54824d2cae66587032a3a02bb576de5e
|
|
| BLAKE2b-256 |
86f028b03189a5d746bca22547a4be5a25d121ab00193ee2c308475818ca200f
|
Provenance
The following attestation bundles were made for tree_sitter_hujson-1.0.1-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on ggfevans/tree-sitter-hujson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_hujson-1.0.1-cp38-abi3-win_amd64.whl -
Subject digest:
c3e659931440eeb6f6b44e8bf8f137de6d2039e6ab365d53182da43368d4ba3c - Sigstore transparency entry: 1708812596
- Sigstore integration time:
-
Permalink:
ggfevans/tree-sitter-hujson@506ab946025772028c0050d8c6b555ef5670f4b5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfevans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@506ab946025772028c0050d8c6b555ef5670f4b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_hujson-1.0.1-cp38-abi3-win32.whl.
File metadata
- Download URL: tree_sitter_hujson-1.0.1-cp38-abi3-win32.whl
- Upload date:
- Size: 13.0 kB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ae5b8ae5913d6a995e3f8559b5610a618e7f0003430f39457b0249b7e273281
|
|
| MD5 |
861e6bdc26b19812b499173a46f615af
|
|
| BLAKE2b-256 |
5cf73088277abd2808f291696a84ba4547611f0e1e2711678ab20e6f68ead4b6
|
Provenance
The following attestation bundles were made for tree_sitter_hujson-1.0.1-cp38-abi3-win32.whl:
Publisher:
release.yml on ggfevans/tree-sitter-hujson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_hujson-1.0.1-cp38-abi3-win32.whl -
Subject digest:
0ae5b8ae5913d6a995e3f8559b5610a618e7f0003430f39457b0249b7e273281 - Sigstore transparency entry: 1708812584
- Sigstore integration time:
-
Permalink:
ggfevans/tree-sitter-hujson@506ab946025772028c0050d8c6b555ef5670f4b5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfevans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@506ab946025772028c0050d8c6b555ef5670f4b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_hujson-1.0.1-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: tree_sitter_hujson-1.0.1-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 18.8 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d68ffa73af7528eb45c1386c5d82fb6064567b6b0d7e264d53fe89ead4fad7fd
|
|
| MD5 |
7af9c890f0f393481fb7fba898fa4f22
|
|
| BLAKE2b-256 |
9aac172816eac411f76009608847c226e12c88fca74a8b6eeefda2794cd33d38
|
Provenance
The following attestation bundles were made for tree_sitter_hujson-1.0.1-cp38-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on ggfevans/tree-sitter-hujson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_hujson-1.0.1-cp38-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
d68ffa73af7528eb45c1386c5d82fb6064567b6b0d7e264d53fe89ead4fad7fd - Sigstore transparency entry: 1708812652
- Sigstore integration time:
-
Permalink:
ggfevans/tree-sitter-hujson@506ab946025772028c0050d8c6b555ef5670f4b5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfevans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@506ab946025772028c0050d8c6b555ef5670f4b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_hujson-1.0.1-cp38-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_hujson-1.0.1-cp38-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 18.9 kB
- Tags: CPython 3.8+, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
648f58d7de45fcf99ca4c92cde60c21be3cf5542838b5e8c550040cc43bff530
|
|
| MD5 |
8497d9cbf4d5cc86734d651d4cd52dfa
|
|
| BLAKE2b-256 |
d809d726f5f309b2dfd82ee6fafac308bce5ff18e4dfc50752369d51b01de656
|
Provenance
The following attestation bundles were made for tree_sitter_hujson-1.0.1-cp38-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl:
Publisher:
release.yml on ggfevans/tree-sitter-hujson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_hujson-1.0.1-cp38-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl -
Subject digest:
648f58d7de45fcf99ca4c92cde60c21be3cf5542838b5e8c550040cc43bff530 - Sigstore transparency entry: 1708812612
- Sigstore integration time:
-
Permalink:
ggfevans/tree-sitter-hujson@506ab946025772028c0050d8c6b555ef5670f4b5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfevans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@506ab946025772028c0050d8c6b555ef5670f4b5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_hujson-1.0.1-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_hujson-1.0.1-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 11.5 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab66db380f74b47d6255b382dbaf2808aa01cd9d8e44759df24a28724d568b76
|
|
| MD5 |
a2674e37837cd70d562a756903c186f7
|
|
| BLAKE2b-256 |
8658042aec4c72511d3973a7222d2bf092f8ffbc43c7ccf59dbc98f7537b231a
|
Provenance
The following attestation bundles were made for tree_sitter_hujson-1.0.1-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on ggfevans/tree-sitter-hujson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_hujson-1.0.1-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
ab66db380f74b47d6255b382dbaf2808aa01cd9d8e44759df24a28724d568b76 - Sigstore transparency entry: 1708812689
- Sigstore integration time:
-
Permalink:
ggfevans/tree-sitter-hujson@506ab946025772028c0050d8c6b555ef5670f4b5 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/ggfevans
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@506ab946025772028c0050d8c6b555ef5670f4b5 -
Trigger Event:
push
-
Statement type: