PHPackages                             mehr-it/easy-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. mehr-it/easy-json

ActiveLibrary

mehr-it/easy-json
=================

Easy JSON handling (read/write) for large files

1.0.3(4y ago)0605MITPHPPHP &gt;=7.3.0

Since Jun 1Pushed 4y agoCompare

[ Source](https://github.com/mehr-it/easy-json)[ Packagist](https://packagist.org/packages/mehr-it/easy-json)[ RSS](/packages/mehr-it-easy-json/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

Easy JSON
=========

[](#easy-json)

Parsing JSON files
------------------

[](#parsing-json-files)

Here is a simple example how to parse large JSON files:

```
(new JsonParser($fh))
    ->eachItem('Library.Books', function($parser, $index) {
        // this callback will be invoked for each book

        $parser
            ->value('Author', $author)
            ->value('ISBN', $isbn)
            ->consume();

        // do s.th. with author and ISBN data

    })
    ->parse();

```

The following example shows how values can be collected:

```
(new JsonParser($fh))
    ->collectItemValues('Library.Books.ISBN', $isbns)
    ->parase();

// $isbns now holds the ISBNs of all books

```

***TODO:*** add more examples and details

Writing JSON files
------------------

[](#writing-json-files)

Here is a simple example how to write JSON files:

```
$builder = new JsonBuilder($fh);

$builder->write([
    'version' => '1.0',
    'users' => new JsonArray(function(JsonBuilder $builder) {
        foreach(getUsers() as $currUser) {
            yield ['name' => $currUser->name];
        }
    }),
]);

```

To force a specific JSON data type, you can use the following classes:

- `JsonArray`
- `JsonObject`
- `JsonNumber`

### Resources

[](#resources)

You can write a resource as JSON string without reading all the stream data into memory:

```
$builder->write(new JsonResourceString($fh))

```

You can optionally encode the data as JSON:

```
$builder->write(new JsonResourceString($fh, true))

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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 ~44 days

Total

5

Last Release

1627d ago

Major Versions

0.8.0 → 1.0.02021-09-13

PHP version history (2 changes)0.8.0PHP &gt;=7.1.0

1.0.0PHP &gt;=7.3.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44973729?v=4)[mehr.IT GmbH](/maintainers/mehr-it)[@mehr-it](https://github.com/mehr-it)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mehr-it-easy-json/health.svg)

```
[![Health](https://phpackages.com/badges/mehr-it-easy-json/health.svg)](https://phpackages.com/packages/mehr-it-easy-json)
```

PHPackages © 2026

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