PHPackages                             wizaplace/json-decoder - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. wizaplace/json-decoder

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

wizaplace/json-decoder
======================

Throw an exception when json\_decode() fails to decode a JSON and validate decoded data.

1.0.1(7y ago)01861MITPHPPHP ^7.1.3

Since Mar 26Pushed 7y agoCompare

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

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

Json-Decoder
============

[](#json-decoder)

Json Decoder Component

How to decode json
------------------

[](#how-to-decode-json)

Do not use `json_decode()`, before PHP 7.3 you have to manually throw exception when decode fail.

Create a JsonDecoder
--------------------

[](#create-a-jsondecoder)

You should create a class for each json you need to decode, who extends `Wizacha\Json\Decoder\AbstractJsonDecoder`.

Your class should configure AbstractJsonDecoder:

```
class FooJsonDecoder extends AbstractJsonDecoder
{
    public function __construct()
    {
        $this
            // throw a Wizacha\Json\Exception\JsonDecodeNullException exception if json_decode() return null
            ->setAllowNull(true)
            // transform objects into associative arrays, 2nd parameter of json_decode()
            ->setAssociative(false)
            // depth, 3nd parameter of json_decode()
            ->setDepth(512)
            // transform bigint as string
            ->setBigIntAsString(false)
            // transform objects as arrays, useless if setAssociative(true)
            ->setObjectAsArray(false);
    }

    protected function configureDecodedJson(OptionsResolver $optionsResolver): parent
    {
        // if json_decode() return an array, configure expected keys
        // @see https://symfony.com/doc/current/components/options_resolver.html

        $optionsResolver
            ->setRequired('myKey')
            ->setAllowedTypes('myKey', 'string');

        return $this;
    }
}
```

Use your JsonDecoder to decode json
-----------------------------------

[](#use-your-jsondecoder-to-decode-json)

If your JsonDecoder don't need dependencies, you could instanciate it manually:

```
$decodedJson = (new FooJsonDecoder())->decode($json);
```

If it need dependencies, register it as Symfony service and use it:

```
$decodedJson = container()->get('json_decoder.foo')->decode($json);
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

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

Total

2

Last Release

2655d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/41571181?v=4)[Cédric Bertolini](/maintainers/wizacedric)[@wizacedric](https://github.com/wizacedric)

---

Top Contributors

[![RomainJaldo](https://avatars.githubusercontent.com/u/34742857?v=4)](https://github.com/RomainJaldo "RomainJaldo (5 commits)")[![steevanb](https://avatars.githubusercontent.com/u/5063383?v=4)](https://github.com/steevanb "steevanb (4 commits)")[![wizacedric](https://avatars.githubusercontent.com/u/41571181?v=4)](https://github.com/wizacedric "wizacedric (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M24.9k](/packages/friendsofphp-php-cs-fixer)[symfony/form

Allows to easily create, process and reuse HTML forms

2.8k162.1M3.4k](/packages/symfony-form)[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k247.1M330](/packages/sentry-sentry)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M733](/packages/sylius-sylius)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.4k67.4M262](/packages/nelmio-api-doc-bundle)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.7M1.0k](/packages/phpro-grumphp)

PHPackages © 2026

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