PHPackages                             germania-kg/jsondecoder - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. germania-kg/jsondecoder

ActiveLibrary[HTTP &amp; Networking](/categories/http)

germania-kg/jsondecoder
=======================

Decode JSON in strings and PSR-7 messages. Supports JsonException on older PHP

1.2.0(3y ago)06911[2 PRs](https://github.com/GermaniaKG/JsonDecoder/pulls)3MITPHPPHP ^7.4|^8.0

Since Apr 16Pushed 3y ago2 watchersCompare

[ Source](https://github.com/GermaniaKG/JsonDecoder)[ Packagist](https://packagist.org/packages/germania-kg/jsondecoder)[ RSS](/packages/germania-kg-jsondecoder/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (6)Versions (12)Used By (3)

[![](https://camo.githubusercontent.com/cac3140c0c6e758f67a1ba689683ced67aa2d534e2187d6e03c5c721ffe3b976/68747470733a2f2f7374617469632e6765726d616e69612d6b672e636f6d2f6c6f676f732f67612d6c6f676f2d323031362d7765622e7376677a)](https://camo.githubusercontent.com/cac3140c0c6e758f67a1ba689683ced67aa2d534e2187d6e03c5c721ffe3b976/68747470733a2f2f7374617469632e6765726d616e69612d6b672e636f6d2f6c6f676f732f67612d6c6f676f2d323031362d7765622e7376677a)

---

JsonDecoder
===========

[](#jsondecoder)

**Decode JSON in strings and PSR-7 messages. Supports *JsonException* on older PHP**.

[![Packagist](https://camo.githubusercontent.com/fe46bd4004d48a3ff1777a38fa1e951d54bb5691c3755e0a0aab655366fcb247/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6765726d616e69612d6b672f6a736f6e6465636f6465722e7376673f7374796c653d666c6174)](https://packagist.org/packages/germania-kg/jsondecoder)[![PHP version](https://camo.githubusercontent.com/5a8f3f6c90c158c4c9c6ac4050fd2c9024160d4d9597e495ca19a7e09359b64c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6765726d616e69612d6b672f6a736f6e6465636f6465722e737667)](https://packagist.org/packages/germania-kg/jsondecoder)[![Tests](https://github.com/GermaniaKG/JsonDecoder/actions/workflows/tests.yml/badge.svg)](https://github.com/GermaniaKG/JsonDecoder/actions/workflows/tests.yml)

Installation with Composer
--------------------------

[](#installation-with-composer)

```
$ composer require germania-kg/jsondecoder
```

Usage
-----

[](#usage)

The callable **JsonDecoder** accepts the same parameters than described in PHP's documentation on [json\_decode](https://www.php.net/manual/en/function.json-decode.php). Additionally, it accepts some widely-used kinds of data:

- `Psr\Http\Message\MessageInterface`
- `Psr\Http\Message\ResponseInterface`
- `Psr\Http\Message\StreamInterface`
- `string`

```
use Germania\JsonDecoder\JsonDecoder;

// Let:
// $response instance of ResponseInterface,
// $body instance of StreamInterface
$body = $response->getBody();
$str = $body->__toString();

try {
  $decoder = new JsonDecoder;
  $decoded = $decoder( $response );
  $decoded = $decoder( $body );
  $decoded = $decoder( $str );
}
catch ( \JsonException $e)
{
  echo $e->getMessage();
}
```

Exceptions
----------

[](#exceptions)

When the decoding fails, a **\\JsonException** (mind the global namespace!) will be thrown. This class is provided by **[Symfony's Polyfill PHP 7.3](https://github.com/symfony/polyfill-php73)** for those lacking PHP 7.3.

Issues
------

[](#issues)

See [full issues list.](https://github.com/GermaniaKG/JsonDecoder/issues)

Development
-----------

[](#development)

```
$ git clone https://github.com/GermaniaKG/JsonDecoder.git
$ cd JsonDecoder
$ composer install
```

Unit tests
----------

[](#unit-tests)

Either copy `phpunit.xml.dist` to `phpunit.xml` and adapt to your needs, or leave as is. Run [PhpUnit](https://phpunit.de/) test or composer scripts like this:

```
$ composer test
# or
$ vendor/bin/phpunit
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 95.8% 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 ~170 days

Recently: every ~179 days

Total

9

Last Release

1227d ago

PHP version history (3 changes)1.0.0PHP ^7.0

1.0.3PHP ^7.0|^8.0

1.2.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ba1899945696f873f95de5e2b8f7519960f1b4e59f61e607b4cbbd8880d244e1?d=identicon)[germania-kg](/maintainers/germania-kg)

---

Top Contributors

[![tomkyle](https://avatars.githubusercontent.com/u/412560?v=4)](https://github.com/tomkyle "tomkyle (46 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![germania-kg](https://avatars.githubusercontent.com/u/7591136?v=4)](https://github.com/germania-kg "germania-kg (1 commits)")

---

Tags

psr-7jsonjson\_decode

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/germania-kg-jsondecoder/health.svg)

```
[![Health](https://phpackages.com/badges/germania-kg-jsondecoder/health.svg)](https://phpackages.com/packages/germania-kg-jsondecoder)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.0B3.2k](/packages/guzzlehttp-psr7)[league/uri-interfaces

Common tools for parsing and resolving RFC3987/RFC3986 URI

538204.9M23](/packages/league-uri-interfaces)[violet/streaming-json-encoder

Library for iteratively encoding large JSON documents piece by piece

3162.1M5](/packages/violet-streaming-json-encoder)[jimtools/jwt-auth

PSR-15 JWT Authentication middleware, A replacement for tuupola/slim-jwt-auth

20142.3k3](/packages/jimtools-jwt-auth)[laminas/laminas-psr7bridge

Bidirectional conversions between PSR-7 and laminas-http messages

117.9M18](/packages/laminas-laminas-psr7bridge)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)

PHPackages © 2026

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