PHPackages                             plumphp/plum-json - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. plumphp/plum-json

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

plumphp/plum-json
=================

v0.3(11y ago)140PHP

Since Feb 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/plumphp/plum-json)[ Packagist](https://packagist.org/packages/plumphp/plum-json)[ RSS](/packages/plumphp-plum-json/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (7)Used By (0)

 [![Plum](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)](https://camo.githubusercontent.com/a81342cbfd6f64a484988488ad37bbd0e665d0f14f65ec655ae986097447bfb6/687474703a2f2f63646e2e666c6f7269616e2e65632f706c756d2d6c6f676f2e737667)
==================================================================================================================================================================================================================================================================================================================================================================

[](#----)

> PlumJsons includes readers, writers and converters for JSON strings and files. Plum is a data processing pipeline for PHP.

[![Build Status](https://camo.githubusercontent.com/9245704cca60ada9f9ddae5844d4c796ed20678b0614887d05bb12711c56d0b3/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f706c756d7068702f706c756d2d6a736f6e2e7376673f7374796c653d666c6174)](https://travis-ci.org/plumphp/plum-json)[![Windows Build status](https://camo.githubusercontent.com/040a476f61f9b77758182850883cc61b511f42246f8267f34839c29758e2bd2b/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f78626533656f3664716d77326c7178613f7376673d74727565)](https://ci.appveyor.com/project/florianeckerstorfer/plum-json)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9874adc1da56d0f5cb753c5adb78891d8bbf5e907f144f18f2531c1dce0112be/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706c756d7068702f706c756d2d6a736f6e2e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/plumphp/plum-json/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/29ab9c5421e37988554d2663a71e8ca90332fcd769d899e7a21bddc67f706018/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f706c756d7068702f706c756d2d6a736f6e2e7376673f7374796c653d666c6174)](https://scrutinizer-ci.com/g/plumphp/plum-json/?branch=master)[![StyleCI](https://camo.githubusercontent.com/611d34c0cd3cc8cb4f3446f0c43441649f2ed43f79add797b279787ba10b0285/68747470733a2f2f7374796c6563692e696f2f7265706f732f33303230343632362f736869656c64)](https://styleci.io/repos/30204626)

Developed by [Florian Eckerstorfer](https://florian.ec) in Vienna, Europe.

Features
--------

[](#features)

### Readers

[](#readers)

- `JsonFileReader` reads a `.json` file from disk and decodes it
- `JsonReader` decodes a JSON string

### Writers

[](#writers)

- `JsonFileWriter` encodes an object/array into JSON and saves it to disk
- `JsonWriter` encodes an object/array into JSON and returns the string

### Converters

[](#converters)

- `JsonDecodeConverter` takes a JSON string and decodes it
- `JsonEncodeConverter` takes an object/array and encodes it to JSON

Installation
------------

[](#installation)

You can install Plum using [Composer](http://getcomposer.org).

```
$ composer require plumphp/plum-json
```

Usage
-----

[](#usage)

Please refer to the [Plum documentation](https://github.com/plumphp/plum/blob/master/docs/index.md) for more information about Plum in general.

### `JsonReader`

[](#jsonreader)

`Plum\PlumJson\JsonReader` reads a JSON string. If you want to read a `.json` file checkout [JsonFileReader](#jsonfilereader).

```
use Plum\PlumJson\JsonReader;

$reader = new JsonReader('[{'key1': 'value1', 'key2': 'value2'}]');
$reader->getIterator(); // -> \ArrayIterator
$reader->count();
```

### `JsonFileReader`

[](#jsonfilereader)

`Plum\PlumJson\JsonFileReader` reads a `.json` file.

```
use Plum\PlumJson\JsonFileReader;

$reader = new JsonFileReader('foo.json');
$reader->getIterator(); // -> \ArrayIterator
$reader->count();
```

### `JsonFileWriter`

[](#jsonfilewriter)

`Plum\PlumJson\JsonFileWriter` writes the items as JSON into a file.

```
use Plum\PlumJson\JsonFileWriter;

$writer = new JsonFileWriter('foobar.json');
$writer->writeItem(['key1' => 'value1', 'key2' => 'value2'));
$writer->finish();
```

It is essential that `finish()` is called, because there happens the actual writing. The `prepare()` method does nothing.

### `JsonWriter`

[](#jsonwriter)

`Plum\PlumJson\JsonWriter` converts the items into JSON format. Please checkout [JsonFileWriter](#jsonfilewriter) if you want to write the JSON into a file.

```
use Plum\PlumJson\JsonWriter;

$writer = new JsonWriter();
$writer->writeItem(['key1' => 'value1', 'key2' => 'value2'));
echo $writer->getJson(); // [{'key1': 'value1', 'key2': 'value2'}]
```

### `JsonDecodeConverter`

[](#jsondecodeconverter)

`Plum\PlumJson\JsonDecodeConverter` uses [Braincrafted\\Json](https://github.com/braincrafted/json) to decode JSON.

```
use Plum\PlumJson\JsonDecodeConverter;
use Braincrafted\Json\Json;

$converter = new JsonDecodeConverter(Json::DECODE_ASSOC);
$converter->convert('{"foo": "bar"}'); // -> ['foo' => 'bar']
```

### `JsonEncodeConverter`

[](#jsonencodeconverter)

`Plum\PlumJson\JsonEncodeConverter` uses [Braincrafted\\Json](https://github.com/braincrafted/json) to encode an object into JSON.

```
use Plum\PlumJson\JsonEncodeConverter;

$converter = new JsonEncodeConverter();
$converter->convert(['foo' => 'bar']); // -> '{"foo": "bar"}'
```

Change Log
----------

[](#change-log)

### Version 0.3 (7 May 2015)

[](#version-03-7-may-2015)

- Add `JsonDecodeConverter`
- Add `JsonEncodeConverter`

### Version 0.2 (22 April 2015)

[](#version-02-22-april-2015)

- Add support for ReaderFactory

### Version 0.1 (17 February 2015)

[](#version-01-17-february-2015)

- Initial release

License
-------

[](#license)

The MIT license applies to plumphp/plum- json. For the full copyright and license information, please view the [LICENSE](https://github.com/plumphp/plum-json/blob/master/LICENSE) file distributed with this source code.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~16 days

Total

6

Last Release

4029d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a80f9fc61cd3a7d7779e8f120b458ca4d18fdd885d719bb77d3379b96bf714d9?d=identicon)[florianeckerstorfer](/maintainers/florianeckerstorfer)

---

Top Contributors

[![florianeckerstorfer](https://avatars.githubusercontent.com/u/149201?v=4)](https://github.com/florianeckerstorfer "florianeckerstorfer (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/plumphp-plum-json/health.svg)

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

###  Alternatives

[cocur/domain

Check domain name availability and WHOIS

691.3k](/packages/cocur-domain)[mckenziearts/laravel-command

A simple Laravel package to provide artisan new commands

321.2k](/packages/mckenziearts-laravel-command)

PHPackages © 2026

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