https://github.com/networkteam/json-seq
JSON Text Sequences (RFC7464) encoder and decoder for PHP
https://github.com/networkteam/json-seq
Last synced: about 2 months ago
JSON representation
JSON Text Sequences (RFC7464) encoder and decoder for PHP
- Host: GitHub
- URL: https://github.com/networkteam/json-seq
- Owner: networkteam
- License: mit
- Created: 2018-07-03T10:11:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-09-11T07:55:32.000Z (over 2 years ago)
- Last Synced: 2026-01-11T15:26:35.919Z (3 months ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Package
[](https://github.com/networkteam/json-seq/releases)
[](https://travis-ci.org/networkteam/json-seq)
[](https://scrutinizer-ci.com/g/networkteam/json-seq)
[](https://scrutinizer-ci.com/g/networkteam/json-seq)
[](https://packagist.org/packages/networkteam/json-seq)
**JSON Text Sequences (RFC7464) encoder and decoder for PHP**
JSON Text Sequences define a streamable JSON encoding and parsing based on a delimiter for multiple JSON encoded texts.
See https://tools.ietf.org/html/rfc7464 for the JSON Text Sequences RFC.
## Install
Via Composer
``` bash
$ composer require networkteam/json-seq
```
## Usage
Encoding data in JSON Text Sequences:
``` php
$stringWriter = new StringWriter();
$encoder = new Encoder($stringWriter);
$encoder->emit(['id' => '1', ...]);
$encoder->emit(['id' => '2', ...]);
$result = $stringWriter->getString();
```
Decoding JSON Text Sequences from a string:
``` php
$jsonTexts = "\x1E{...}\x0A\x1E{...}\x0A";
$decoder = new StringDecoder();
foreach ($decoder->decode($jsonTexts) as $data) {
// process $data
}
```
## Testing
``` bash
$ composer test
```
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.