Package Usage: go: 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:
5 versions
Latest release: over 2 years ago
116 dependent packages
View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/github.com/tailscale/hujson