PHPackages                             machitgarha/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. machitgarha/json

Abandoned → [webmozart/json](/?search=webmozart%2Fjson)ArchivedLibrary[Utility &amp; Helpers](/categories/utility)

machitgarha/json
================

A package for handling JSON data, focusing on performance

1.0.2(6y ago)115711MITPHPPHP ^7.0

Since Jan 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/machitgarha/Json)[ Packagist](https://packagist.org/packages/machitgarha/json)[ Docs](https://github.com/MAChitgarha/Json)[ RSS](/packages/machitgarha-json/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (9)Dependencies (3)Versions (33)Used By (1)

Json
====

[](#json)

[![Release](https://camo.githubusercontent.com/b9e6ebcfa4605c1efc23a019e09155750ebe74d1df6545731b8a8d1c27ec2fd8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6d616368697467617268612f6a736f6e2e7376673f6c6162656c3d52656c6561736526636f6c6f723d6461726b626c7565267374796c653d706f706f75742d737175617265)](https://camo.githubusercontent.com/b9e6ebcfa4605c1efc23a019e09155750ebe74d1df6545731b8a8d1c27ec2fd8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f6d616368697467617268612f6a736f6e2e7376673f6c6162656c3d52656c6561736526636f6c6f723d6461726b626c7565267374796c653d706f706f75742d737175617265)[![License](https://camo.githubusercontent.com/9156a82960345cdbfa76cd126081485795b2f488ebb1e5857628e063b82747c4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d616368697467617268612f6a736f6e2e7376673f6c6162656c3d4c6963656e736526636f6c6f723d6461726b626c7565267374796c653d706f706f75742d737175617265)](LICENSE.md)[![Code Quality](https://camo.githubusercontent.com/7ebbe8fa9f097f599bb59cd9ac7a1af317d0c8e9ca726ec677c9945d1679a51a/68747470733a2f2f696d672e736869656c64732e696f2f636f6465666163746f722f67726164652f6769746875622f6d616368697467617268612f6a736f6e2f6d61737465722e7376673f6c6162656c3d436f64652532305175616c697479267374796c653d666c61742d737175617265)](https://www.codefactor.io/repository/github/machitgarha/json)[![Build](https://camo.githubusercontent.com/660f4d736a891f5409b92d9d1ce408a142a86c2124c5ae42a2bd051e506d3cb0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d616368697467617268612f6a736f6e3f7374796c653d666c61742d737175617265)](https://travis-ci.org/MAChitgarha/Json)

No Longer Maintained
--------------------

[](#no-longer-maintained)

This repository is no longer maintained, and is deprecated. Its use is highly discouraged.

We don't need yet another Json package, because neither there is a need for it, nor it provide a unique or useful feature. Let's focus on something that matters more, or at least on improving existing libraries, projects, etc. If you think it's a wrong decision (e.g. you are an active user of this library and can't find an alternative), please open an issue.

This repository should be considered of a showcase of what I've done. Feel free to switch to the branch `develop`, and guess what version 2.0.0 would look like, and think how it could ever solve a single problem.

An alternative to this library would be [Webmozart Json](https://github.com/webmozart/json).

What's it?
----------

[](#whats-it)

A component for your JSON data. Huh! Just that? No! Continue reading.

Why Json?
---------

[](#why-json)

### Performance

[](#performance)

**Note:** Unfortunately, the library performance seems not to be scalable. A bright result of micro-optimizations. A result of focusing on what matters least. See [\#59](https://github.com/machitgarha/Json/issues/59) for more details.

### Flexible

[](#flexible)

- Json is not only for JSON data. So what? Many types are supported, including JSON strings, arrays, objects and scalars (+ null). Resources are not supported, and won't be supported (because of the standards).
- Use methods regardless of the data type. Merging two objects? Actually.
- Do anything, even if not provided by the class, using a callable. Alternatives? Extend from the class and define your own things. For sure, it will be easy in both cases.
- Oh, what if an index does not exist? Exception. Parsing bad JSON data? Exception, again. Warnings and notices? Very rare cases.

### Many Ways

[](#many-ways)

Like JavaScript dots to get indexes, or native PHP arrays? Choose. Even with JavaScript-like indexes, you can pass the index to a method or you can use `Json::index()`. It is your decision.

Example
-------

[](#example)

An example from [PHPUnit](https://github.com/sebastianbergmann/phpunit/blob/256901b90d55163005669ec29d5646c357f3d7ef/src/Util/Json.php#L24) source code:

```
function prettify(string $json): string {
    $decodedJson = \json_decode($json, true);

    if (\json_last_error()) {
        throw new Exception(
            'Cannot prettify invalid json'
        );
    }

    return \json_encode($decodedJson, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES);
}
```

Looks good, but it can be really better:

```
// use MAChitgarha\Component\Json

function prettify(string $jsonStr): string {
    return Json::new($jsonStr)->getAsJson(\JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES);
}
```

Advantages:

- Handling different exceptions is easier. Not just getting "Cannot prettify invalid json". Get exception message based on the error happened. Debugging will be easier.
- Less code. Looks prettier. One line. Besides, sometimes, you don't even need to define that method, use Json directly without a function overhead.

Good! What Do I Need?
---------------------

[](#good-what-do-i-need)

Almost nothing. PHP7, the [JSON extension](https://www.php.net/manual/en/book.json.php) that comes with PHP7 by default, and usually Composer.

Installing
----------

[](#installing)

Composer is there!

```
composer require machitgarha/json

```

**Note**: You can also clone the project and load the files in your own way. The recommended way is Composer, however.

Documentation
-------------

[](#documentation)

**Note**: The documentation is outdated, wrt to version 1.0.0+.

See [the GitHub wiki](https://github.com/MAChitgarha/Json/wiki).

Contribution?
-------------

[](#contribution)

Although the library is no longer maintained, but you can see contribution guidelines [here](.github/CONTRIBUTING.md).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

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

Total

29

Last Release

2453d ago

Major Versions

0.3.4 → 1.0.0-alpha.12019-06-13

### Community

Maintainers

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

---

Top Contributors

[![machitgarha](https://avatars.githubusercontent.com/u/14151550?v=4)](https://github.com/machitgarha "machitgarha (406 commits)")

---

Tags

arraysfastjsonobjectsperformancephpphp7jsonarrayperformanceobjectfastPHP7speed

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k394.3M1.5k](/packages/nette-utils)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[jbzoo/data

An extended version of the ArrayObject object for working with system settings or just for working with data arrays

891.6M23](/packages/jbzoo-data)[jasny/dotkey

Dot notation access for objects and arrays

14219.5k6](/packages/jasny-dotkey)[zakirullin/mess

Convenient array-related routine &amp; better type casting

21228.9k2](/packages/zakirullin-mess)

PHPackages © 2026

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