Download the PHP package ustek/hujson without Composer

On this page you can find all versions of the php package ustek/hujson. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hujson

ustek/hujson

A PHP port of tailscale/hujson: a parser and packer for the JWCC format — JSON With Commas and Comments (also called "human JSON"). JWCC extends RFC 8259 JSON with line comments (// ...), block comments (/* ... */), and trailing commas.

It parses into a lossless syntax tree: comments, whitespace, and byte offsets are all preserved, so you can read, transform, and write a document back byte-for-byte unchanged unless you deliberately modify it.

JWCC is well suited to configuration files that benefit from comments and a forgiving syntax while staying close to standard JSON. This is a general-purpose JWCC library with no runtime dependencies beyond PHP core.

Requirements

Installation

Quick start

The HuJSON facade covers the common whole-document operations. Each throws Ustek\HuJSON\HuJSONException on a parse error, with a Go-compatible message such as hujson: line 1, column 6: invalid character ',' after top-level value.

A common pattern is to feed standardize() (or minimize()) output into json_decode():

The syntax tree

HuJSON::parse() returns a Value — an exact syntactic representation of the input.

Value exposes:

Member Description
?string $beforeExtra, ?string $afterExtra Surrounding comments/whitespace (null = none)
int $startOffset, int $endOffset Byte offsets of the value
?ValueTrimmed $value The trimmed value: a Literal, ObjectValue, or ArrayValue
pack(): string / (string) $v Serialize to HuJSON
isStandard(): bool True if standard JSON (no comments, no trailing commas)
minimize(), standardize(), format() In-place transforms
find(string $pointer): ?Value Look up a node by JSON Pointer (RFC 6901)
patch(string $patch): void Apply a JSON Patch (RFC 6902), preserving comments
all(): Generator, range(callable): bool Depth-first traversal
updateOffsets(): void Recompute startOffset/endOffset

Deep-copy a value with clone before mutating if you need to keep the original:

Navigating and editing

Literals

Literal is immutable (public readonly string $bytes) with constructors and typed accessors:

Command-line tool

The package ships a hujsonfmt binary (a port of the upstream Go command):

Flag Effect
(none) Format and print to stdout
-m Minify to standard JSON
-s Standardize to standard JSON (preserving offsets)
-d Print a unified diff instead of the result
-l List files whose formatting differs
-w Rewrite the file(s) in place (with a temp backup)

With no path (or -) it reads stdin. A directory argument is walked recursively, processing files ending in .hujson.

Go → PHP API map

Go (tailscale/hujson) PHP (Ustek\HuJSON)
hujson.Parse HuJSON::parse
hujson.Standardize / Minimize / Format HuJSON::standardize / minimize / format
Value.Pack / Value.String Value::pack / (string) $v
Value.Clone clone $value
Value.IsStandard / Find / Patch / UpdateOffsets same, camelCase
Value.All / Value.Range Value::all / Value::range
hujson.Bool/String/Int/Uint/Float Literal::fromBool/fromString/fromInt/fromUint/fromFloat
Literal.Bool/String/Int/Uint/Float/IsValid/Kind asBool/asString/asInt/asUint/asFloat/isValid/kind
Object / Array / composite ObjectValue / ArrayValue / Composite

Behaviour notes

Development

The golden test tables in tests/fixtures/golden.json are extracted verbatim from the upstream Go test files, so the suite runs fully offline. An optional tests/DifferentialTest.php cross-checks a broad corpus against a Go reference oracle for byte-identical output; it self-skips unless that oracle is present locally, so it never runs in a normal checkout.

License

BSD-3-Clause. This is a port of tailscale/hujson; the original copyright (Tailscale Inc & AUTHORS) is retained in LICENSE.


All versions of hujson with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ustek/hujson contains the following files

Loading the files please wait ...