Download the PHP package joelwurtz/json-stream without Composer
On this page you can find all versions of the php package joelwurtz/json-stream. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download joelwurtz/json-stream
More information about joelwurtz/json-stream
Files in joelwurtz/json-stream
Package json-stream
Short Description Lazy, streaming JSON decoding: json_stream_decode() returns an array-accessible document that only parses the paths you access, with SIMD-accelerated scanning and constant-memory transient iteration
License MIT
Informations about the package json-stream
json_stream
PHP extension for lazy, streaming JSON decoding.
$source may be a string, a stream resource, an array of string chunks,
or any Traversable yielding string chunks (e.g. a Generator). Nothing is
read from the source until the first access on the returned
JsonStream\Document.
For environments where the extension cannot be installed, a separately
installable pure-PHP fallback is available as
joelwurtz/json-stream-polyfill.
$depth has json_decode() semantics (maximum nesting depth, default 512,
must be greater than 0); exceeding it throws JsonException with
JSON_ERROR_DEPTH at the access that reaches the too-deep value.
$options accepts the relevant JSON_* flags (JSON_BIGINT_AS_STRING,
JSON_INVALID_UTF8_IGNORE, JSON_INVALID_UTF8_SUBSTITUTE) plus:
JSON_STREAM_TRANSIENT— forward-only streaming:foreachover a container releases consumed input as it goes, so arbitrarily large streams iterate in constant memory. Once iteration starts the document is forward-only (random access and re-iteration throw).
Status: the lazy engine is live — a resumable simdjson-style SIMD structural
indexer (AVX2/SSSE3/SSE2 on x86_64, NEON/PMULL on aarch64, scalar fallback)
feeds a three-state field model (unread → buffered span → parsed zval). Only
the accessed path is ever materialized: sibling fields are recorded as byte
spans, nested containers become lazy child documents sharing the parser
state. See PLAN.md for the roadmap and the documented divergences
from json_decode.
Install
With PIE (once published on Packagist):
Or build from source:
Polyfill
A pure-PHP polyfill of the full API lives in polyfill/: require
polyfill/bootstrap.php (or use the package's Composer files autoload) and
json_stream_decode() / JsonStream\Document work without the extension —
much slower, but with the same lazy and constant-memory (transient) behavior.
See polyfill/README.md for limits.