github.com/tailscale/hujson
Package hujson contains a parser and packer for the JWCC format: JSON With Commas and Comments (or "human JSON"). JWCC is an extension of standard JSON (as defined in RFC 8259) in order to make it more suitable for humans and configuration files. In particular, it supports line comments (e.g., //...), block comments (e.g., /*...*/), and trailing commas after the last member or element in a JSON object or array. See https://nigeltao.github.io/blog/2021/json-with-commas-comments.html The Parse function parses HuJSON input as a Value, which is a syntax tree exactly representing the input. Comments and whitespace are represented using the Extra type. Composite types in JSON are represented using the Object and Array types. Primitive types in JSON are represented using the Literal type. The Value.Pack method serializes the syntax tree as raw output, which is byte-for-byte identical to the input if no transformations were performed on the value. A HuJSON value can be transformed using the Minimize, Standardize, Format, or Patch methods. Each of these methods mutate the value in place. Call the Clone method beforehand in order to preserve the original value. The Minimize and Standardize methods coerces HuJSON into standard JSON. The Format method formats the value; it is similar to `go fmt`, but instead for the HuJSON and standard JSON format. The Patch method applies a JSON Patch (RFC 6902) to the receiving value. The changes to the JSON grammar are: This package operates with HuJSON as an AST. In order to parse HuJSON into arbitrary Go types, use this package to parse HuJSON input as an AST, strip the AST of any HuJSON-specific lexicographical elements, and then pack the AST as a standard JSON output. Example usage:
proxy.golang.org
v0.0.0-20250605163823-992244df8c5a
10 months ago
6
116
128
Links
| Registry | proxy.golang.org |
| Source | Repository |
| Docs | Documentation |
| JSON API | View JSON |
| CodeMeta | codemeta.json |
Package Details
| PURL |
pkg:golang/github.com/tailscale/hujson
spec |
| License | BSD-3-Clause |
| Namespace | github.com/tailscale |
| First Release | almost 4 years ago |
| Last Synced | about 20 hours ago |
Repository
| Stars | 758 on GitHub |
| Forks | 25 on GitHub |
| Docker Dependents | 67 |
| Docker Downloads | 19,474,779 |
| Commits | 29 |
| Committers | 9 |
| Avg per Author | 3.222 |
| DDS | 0.517 |