2017 © Pedro Peláez
 

library json-streaming-parser

A streaming parser for JSON in PHP.

image

salsify/json-streaming-parser

A streaming parser for JSON in PHP.

  • Thursday, March 29, 2018
  • by kryptonik
  • Repository
  • 63 Watchers
  • 373 Stars
  • 226,191 Installations
  • PHP
  • 8 Dependents
  • 3 Suggesters
  • 89 Forks
  • 13 Open issues
  • 12 Versions
  • 13 % Grown

The README.md

Streaming JSON parser for PHP

Build Status GitHub tag Packagist Coverage Status Minimum PHP Version License, (*1)

This is a simple, streaming parser for processing large JSON documents. Use it for parsing very large JSON documents to avoid loading the entire thing into memory, which is how just about every other JSON parser for PHP works., (*2)

For more details, I've written up a longer explanation of the JSON streaming parser that talks about pros and cons vs. the standard PHP JSON parser., (*3)

If you've ever used a SAX parser for XML (or even JSON) in another language, that's what this is. Except for JSON in PHP., (*4)

This package is compliant with PSR-4, PSR-1, and PSR-2. If you notice compliance oversights, please send a patch via pull request., (*5)

Installation

To install JsonStreamingParser you can either clone this repository or you can use composer, (*6)

composer require salsify/json-streaming-parser

Usage

To use the JsonStreamingParser you just have to implement the \JsonStreamingParser\Listener interface. You then pass your Listener into the parser., (*7)

For example:, (*8)

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

That's it! Your Listener will receive events from the streaming parser as it works., (*9)

There is a complete example of this in example/example.php., (*10)

Running tests

make test

Projects using this library

JSON Collection Parser, (*11)

JSON Objects, (*12)

License

MIT License (c) Salsify, Inc., (*13)

The Versions

29/03 2018

dev-master

9999999-dev https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • ext-mbstring *
  • php ^5.4 | ^7.0

 

The Development Requires

by Maxim Gnatenko

parser json streaming

02/09 2017

v6.0.3

6.0.3.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php ^5.4 | ^7.0
  • ext-mbstring *

 

The Development Requires

by Maxim Gnatenko

parser json streaming

09/04 2017

v6.0.2

6.0.2.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php ^5.4 | ^7.0
  • ext-mbstring *

 

The Development Requires

by Maxim Gnatenko

parser json streaming

02/04 2016

v6.0.1

6.0.1.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php ^5.4 | ^7.0
  • ext-mbstring *

 

The Development Requires

by Maxim Gnatenko

parser json streaming

20/03 2016

v6.0

6.0.0.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php ^5.4 | ^7.0
  • ext-mbstring *

 

The Development Requires

by Maxim Gnatenko

parser json streaming

13/03 2016

v5.1.0

5.1.0.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Maxim Gnatenko

parser json streaming

01/11 2015

v5.0

5.0.0.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Maxim Gnatenko

parser json streaming

07/03 2015

v4.0

4.0.0.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Maxim Gnatenko

parser json streaming

24/01 2015

dev-in-memory-parser-nested-keys

dev-in-memory-parser-nested-keys https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Maxim Gnatenko

parser json streaming

28/05 2014

v3.0

3.0.0.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Maxim Gnatenko

parser json streaming

13/12 2013

v2.0

2.0.0.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Maxim Gnatenko

parser json streaming

31/10 2013

v1.0

1.0.0.0 https://github.com/salsify/jsonstreamingparser

A streaming parser for JSON in PHP.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

by Maxim Gnatenko

parser json streaming