PHPackages                             cerbero/json-objects - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. cerbero/json-objects

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

cerbero/json-objects
====================

Extract objects from large JSON files, endpoints or streams while saving memory.

v1.2.0(5y ago)2229.3k↑12.5%1MITPHPPHP ^7.1||^8.0

Since Mar 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/cerbero90/json-objects)[ Packagist](https://packagist.org/packages/cerbero/json-objects)[ Docs](https://github.com/cerbero90/json-objects)[ RSS](/packages/cerbero-json-objects/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (8)Used By (0)

JSON Objects
============

[](#json-objects)

[![Author](https://camo.githubusercontent.com/fffbc89ca2742dccf8be167716e04b7125a913abae0da6a488131999dab8ca25/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d617574686f72266d6573736167653d6365726265726f393026636f6c6f723d353041424631266c6f676f3d74776974746572267374796c653d666c61742d737175617265)](https://twitter.com/cerbero90)[![PHP Version](https://camo.githubusercontent.com/110f3c1d4a31fc7a432074790ee8be2f467a964d2a2fc4d59f7331ad5c1b0831/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6365726265726f2f6a736f6e2d6f626a656374733f636f6c6f723d253233344635423933266c6f676f3d706870267374796c653d666c61742d737175617265)](https://www.php.net)[![Build Status](https://camo.githubusercontent.com/60eef28c54c773b0e2f563413c687254cf54149db7faf6e0fa207fe20777b8ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6365726265726f39302f6a736f6e2d6f626a656374732f6275696c643f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/cerbero90/json-objects/actions?query=workflow%3Abuild)[![Coverage Status](https://camo.githubusercontent.com/ee7be7a6462d8c13c4c7eb89e78698d7e4e33cdb025b73e68010326f5230b53d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6365726265726f39302f6a736f6e2d6f626a656374732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/cerbero90/json-objects/code-structure)[![Quality Score](https://camo.githubusercontent.com/bdb2ff46bb8934af2470c75759ec325d1d8a7250b3b3139ae9e1b72671b97e1b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6365726265726f39302f6a736f6e2d6f626a656374732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/cerbero90/json-objects)[![Latest Version](https://camo.githubusercontent.com/ba32755b7d5008f3f316205cdc1970130a7a08a31c93a5297a855f3fd93dbfe3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6365726265726f2f6a736f6e2d6f626a656374732e7376673f6c6162656c3d76657273696f6e267374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/json-objects)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![PSR-7](https://camo.githubusercontent.com/6fb7c9a2ea9df36409e75d99da4cf1f64aa28a57e3d03a8c0b769d72e6d31fe6/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d636f6d706c69616e6365266d6573736167653d5053522d3726636f6c6f723d626c7565267374796c653d666c61742d737175617265)](https://www.php-fig.org/psr/psr-7/)[![PSR-12](https://camo.githubusercontent.com/9ba5754b3504e97a10e2b2f84770a218e69e544e9de8943eceb0b67599c83c6c/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d636f6d706c69616e6365266d6573736167653d5053522d313226636f6c6f723d626c7565267374796c653d666c61742d737175617265)](https://www.php-fig.org/psr/psr-12/)[![Total Downloads](https://camo.githubusercontent.com/08f084876c194e2924b6069438dda559521064bab48d6ebe7471391593e181ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6365726265726f2f6a736f6e2d6f626a656374732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/json-objects)

This package extracts JSON objects from large JSON sources like files, endpoints and streams while saving memory. It parses heavy JSONs by using [JsonStreamingParser](https://github.com/salsify/jsonstreamingparser) and provides an easy API to declare what objects to extract and process.

Install
-------

[](#install)

Via Composer

```
composer require cerbero/json-objects
```

Usage
-----

[](#usage)

Simply pass the JSON source (files, endpoints or streams) and optionally the key where objects are contained to create a new instance of `JsonObjects`. You can also call the factory method `from()`:

```
$source = 'https://jsonplaceholder.typicode.com/users';

// Create a new instance specifying the JSON source to extract objects from
new JsonObjects($source);
// or
JsonObjects::from($source);

// Create a new instance specifying the JSON source and the key to extract objects from
new JsonObjects($source, 'address.geo');
// or
JsonObjects::from($source, 'address.geo');
```

When providing a key to extract objects from, you can use the dot notation to indicate nested sections of a JSON. For example `nested.*.key` extracts all the objects in the property `key` of every object contained in `nested`.

Under the hood `JsonObjects` supports PSR-7, hence any implementation of [MessageInterface](https://github.com/php-fig/http-message/blob/master/src/MessageInterface.php) or [StreamInterface](https://github.com/php-fig/http-message/blob/master/src/StreamInterface.php) is a valid source. This makes interactions with other packages supporting PSR-7 (e.g. Guzzle) even more convenient:

```
$response = $guzzle->get('https://jsonplaceholder.typicode.com/users');

// Create a new instance by passing an implementation of MessageInterface
JsonObjects::from($response);

// Create a new instance by passing an implementation of StreamInterface
JsonObjects::from($response->getBody());
```

Finally you can decide whether to extract and process objects one by one or in chunks. The memory will be allocated to read only these objects instead of the whole JSON document:

```
// Extract and process one object at a time from the given JSON source
JsonObjects::from($source)->each(function (array $object) {
    // Process one object
});

// Extract and process a chunk of objects at a time from the given JSON source
JsonObjects::from($source)->chunk(100, function (array $objects) {
    // Process 100 objects
});
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Andrea Marco Sartori](https://twitter.com/cerbero90)
- [JsonStreamingParser](https://github.com/salsify/jsonstreamingparser)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity69

Established project with proven stability

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

Recently: every ~165 days

Total

6

Last Release

1951d ago

PHP version history (2 changes)v1.0.0PHP ~7.1

v1.2.0PHP ^7.1||^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/596523?v=4)[Matteo Picciolini](/maintainers/cerbero)[@cerbero](https://github.com/cerbero)

---

Top Contributors

[![cerbero90](https://avatars.githubusercontent.com/u/5838106?v=4)](https://github.com/cerbero90 "cerbero90 (44 commits)")

---

Tags

streamjsonparsercerberojson-objects

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/cerbero-json-objects/health.svg)

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

###  Alternatives

[salsify/json-streaming-parser

A streaming parser for JSON in PHP.

7766.7M15](/packages/salsify-json-streaming-parser)[cerbero/json-parser

Zero-dependencies pull parser to read large JSON from any source in a memory-efficient way.

803474.6k5](/packages/cerbero-json-parser)[pcrov/jsonreader

JSON Pull Parser

1451.2M5](/packages/pcrov-jsonreader)[maxakawizard/json-collection-parser

Streaming parser for large JSON files containing array of objects

132833.5k8](/packages/maxakawizard-json-collection-parser)[bcncommerce/json-stream

A bundle of tools to work with JSON in PHP

642.2M3](/packages/bcncommerce-json-stream)[laktak/hjson

JSON for Humans. A configuration file format with relaxed syntax, fewer mistakes and more comments.

86233.7k12](/packages/laktak-hjson)

PHPackages © 2026

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