A streaming parser for JSON in PHP.

Installs: 4 766

Dependents: 0

Stars: 1

Watchers: 1

Forks: 35

Open Issues: 1

v4.0.0 2014-07-04 14:50 UTC


Build Status

Code forked from and some fixed added:

  • Removed file_position callback from listener (we did not need it and it gave significant performance boost)
  • PSR2


  • Stream based - low memory footprint does not grow with file size
  • Similar to SAX parser

Known drawbacks

  • Performance is not as good as it should be (throughput - ~1MB per 9 secs, VirtualBox, Debian 7 on 4.3GHz CPU, single core)


To use the JsonStreamingParser you just have to implement the JsonStreamingParser\Listener interface. You then pass your Listener into the parser. For example:

$stream = fopen('doc.json', 'r');
$listener = new YourListener();
try {
  $parser = new Parser($stream, $listener);
} catch (Exception $e) {
  throw $e;

That's it! Your Listener will receive events from the streaming parser as it works.


MIT License