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 4d 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 49% 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

2607d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4015c01b8f256efe17b62e3e210ec2996380048ed9d903e7c2ee50fd1ea55339?d=identicon)[wizacedric](/maintainers/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

[jschaedl/iban-validation

A small library for validating International BankAccount Numbers (IBANs).

1022.8M16](/packages/jschaedl-iban-validation)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65378.4k9](/packages/awurth-slim-validation)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[isometriks/spam-bundle

Provides spam protection for Symfony forms

46200.6k1](/packages/isometriks-spam-bundle)

PHPackages © 2026

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