Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kelunik/streaming-json
A streaming JSON parser based on Amp.
https://github.com/kelunik/streaming-json
amphp async json php streaming
Last synced: 2 months ago
JSON representation
A streaming JSON parser based on Amp.
- Host: GitHub
- URL: https://github.com/kelunik/streaming-json
- Owner: kelunik
- Created: 2017-05-22T07:00:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-10T11:31:59.000Z (over 7 years ago)
- Last Synced: 2024-10-10T18:50:51.561Z (3 months ago)
- Topics: amphp, async, json, php, streaming
- Language: PHP
- Size: 9.77 KB
- Stars: 17
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# streaming-json
A streaming JSON parser for Amp.
## Installation
```
composer require kelunik/streaming-json
```## Usage
```php
$parser = new StreamingJsonParser($inputStream);while (yield $parser->advance()) {
$parsedItem = $parser->getCurrent();
}
```Options can be passed to the constructor just like for `json_decode`. The parser will consume the passed input stream and is itself an `Amp\Iterator` that allows consumption of all parsed items. Any malformed message will fail the parser. If the input stream ends, the parser will try to parse the last item and will complete the iterator successfully or fail it, depending on whether the last item was malformed or not.