PHPackages                             joelwurtz/json-stream - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. joelwurtz/json-stream

ActivePhp-ext

joelwurtz/json-stream
=====================

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

01↑2900%CCI failing

Since Jul 23Pushed todayCompare

[ Source](https://github.com/joelwurtz/php-json-stream)[ Packagist](https://packagist.org/packages/joelwurtz/json-stream)[ RSS](/packages/joelwurtz-json-stream/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

json\_stream
============

[](#json_stream)

PHP extension for lazy, streaming JSON decoding.

```
$data = json_stream_decode($source, $options);
echo $data['foo']['bar'];
```

`$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`.

`$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: `foreach` over 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).

```
$doc = json_stream_decode(fopen('huge.json', 'r'), JSON_STREAM_TRANSIENT);
foreach ($doc['rows'] ?? $doc as $row) {
    handle($row['id'], $row['payload']);
}
```

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](PLAN.md) for the roadmap and the documented divergences from `json_decode`.

Install
-------

[](#install)

With [PIE](https://github.com/php/pie) (once published on Packagist):

```
pie install joelwurtz/json-stream
```

Or build from source:

```
phpize
./configure --enable-json_stream
make
NO_INTERACTION=1 make test
```

Polyfill
--------

[](#polyfill)

A pure-PHP polyfill of the full API lives in [polyfill/](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](polyfill/README.md) for limits.

###  Health Score

21

—

LowBetter than 17% of packages

Maintenance65

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/16ce838e2759f19597de56865243a88711d822ba923c61e024090e87e4d3fc5f?d=identicon)[joelwurtz](/maintainers/joelwurtz)

---

Top Contributors

[![joelwurtz](https://avatars.githubusercontent.com/u/90466?v=4)](https://github.com/joelwurtz "joelwurtz (21 commits)")

### Embed Badge

![Health badge](/badges/joelwurtz-json-stream/health.svg)

```
[![Health](https://phpackages.com/badges/joelwurtz-json-stream/health.svg)](https://phpackages.com/packages/joelwurtz-json-stream)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
