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

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

greenskies/json
===============

An improved php json library

0.2.0(7y ago)05MITPHP

Since Mar 3Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (5)Versions (5)Used By (0)

[![Codacy Badge](https://camo.githubusercontent.com/4f38d6502026aeaa1ff7696ae96ae828b196d733b8e290c6933baa42decdd478/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3835323732643562343163333437316439356636636561613332653065393062)](https://app.codacy.com/app/eidsonator/json?utm_source=github.com&utm_medium=referral&utm_content=greenskies/json&utm_campaign=Badge_Grade_Dashboard)[![author](https://camo.githubusercontent.com/8db2b498b4c7d443f513e5bd642ae83f79029a228e35c3093231eb87ccf77246/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d253430746f6464656964736f6e2d626c75652e737667)](https://eidson.info)[![Coverage Status](https://camo.githubusercontent.com/063e4a689f42e8bff5a9410afb47163ee2ab71e11ef4f0db2f3e7e438c31bab4/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f677265656e736b6965732f6a736f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/greenskies/json?branch=master)[![Build Status](https://camo.githubusercontent.com/88e386e189fdc918cd966d1ef0ec01d6d660c2fdfd17afa1f87990142de18962/68747470733a2f2f7472617669732d63692e6f72672f677265656e736b6965732f6a736f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/greenskies/json)

Greenskies Json
===============

[](#greenskies-json)

A PHP library to improve decoding - including schema validation and decoding to a class

It is basically a wrapper for:

- [karriereat/json-decoder](https://github.com/karriereat/json-decoder)
- [justinrainbow/json-schema](https://github.com/justinrainbow/json-schema)With a little syntatic sugar and exceptions, even on PHP &lt; 7.3

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

[](#installation)

```
composer require greenskies/json
```

Decoding
--------

[](#decoding)

To decode a json string simply pass the string to `Json::Decode()`This will return a standard object

```
$jsonString = '{"good":true}';

$decoded = Json::Decode($jsonString);

// $decoded->good = true
```

```
$jsonString = '{"good":true}';
$options = [
    Json::ASSOCIATIVE => true,
];
$decoded = Json::Decode($jsonString, $options);
// $decoded['good'] = true
```

Schema Validation
-----------------

[](#schema-validation)

```
$jsonString = '{"processRefund": "true", "refundAmount": "17"}'

$schema = (object) [
    "type"=>"object",
    "properties"=>(object)[
        "processRefund"=>(object)[
            "type"=>"boolean"
        ],
        "refundAmount"=>(object)[
            "type"=>"number"
        ]
    ]
];

$options = [
    Json::VALIDATOR => [
        Json::JSON_SCHEMA => $schema,
        Json::CONSTRAINTS => Constraint::CHECK_MODE_COERCE_TYPES,
    ],
];

$decoded = Json::Decode($jsonString, $options);
```

For further instructions visit [justinrainbow/json-schema](https://github.com/justinrainbow/json-schema)

Decode to a class
-----------------

[](#decode-to-a-class)

```
$jsonString = '{"id": 1, "name": "John Doe"}';

$options = [
    Json::DECODER => [
        Json::CLASS_NAME => Person::class,
    ],
];
$decoded = Json::Decode($jsonString, $options);
```

### Decode Multiple

[](#decode-multiple)

```
$jsonString = '[{"id": 1, "name": "John Doe"}, {"id": 2, "name": "Jane Doe"}]';

$options = [
    Json::DECODER => [
        Json::CLASS_NAME => Person::class,
        Json::DECODE_MULTIPLE => true,
    ],
];

$personArray = Json::Decode($jsonString, $options);
```

For further instructions visit [karriereat/json-decoder](https://github.com/karriereat/json-decoder)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~1 days

Total

4

Last Release

2672d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6c40dd9614d98be40f93c63b7ae0b40c87d8db58b28fefbdeab66b61b22b368c?d=identicon)[eidsonator](/maintainers/eidsonator)

---

Top Contributors

[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")[![eidsonator](https://avatars.githubusercontent.com/u/954092?v=4)](https://github.com/eidsonator "eidsonator (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.0k](/packages/composer-composer)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k245.4M24.2k](/packages/friendsofphp-php-cs-fixer)[symfony/rate-limiter

Provides a Token Bucket implementation to rate limit input and output in your application

27054.3M262](/packages/symfony-rate-limiter)[symfony/ldap

Provides a LDAP client for PHP on top of PHP's ldap extension

1408.1M57](/packages/symfony-ldap)[akeneo/pim-community-dev

Akeneo PIM, the future of catalog management is open!

1.0k624.1k86](/packages/akeneo-pim-community-dev)[paycore/openfintech-data

Openfintech data

22010.0k](/packages/paycore-openfintech-data)

PHPackages © 2026

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