PHPackages                             pnz/json-exception - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. pnz/json-exception

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

pnz/json-exception
==================

Json decode/encode library with exception throwing on error.

v1.0.1(4y ago)1385.7k↓37.4%1[1 issues](https://github.com/thePanz/json-exception/issues)2GPL-3.0PHPPHP ^7.0 || ^8.0

Since Nov 7Pushed 4y ago1 watchersCompare

[ Source](https://github.com/thePanz/json-exception)[ Packagist](https://packagist.org/packages/pnz/json-exception)[ RSS](/packages/pnz-json-exception/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (4)Used By (2)

JSON-Exception
==============

[](#json-exception)

[![Latest Version](https://camo.githubusercontent.com/c620caac663c9b098dd2f7b41f9af4b472137cc37d5b3ff59265163fa58bb524/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f74686550616e7a2f6a736f6e2d657863657074696f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/thePanz/json-exception/releases)[![Downloads](https://camo.githubusercontent.com/e8fe1485fba3659f2c568898ccf89c411f73562b8c49db1407e377f2156c1a30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706e7a2f6a736f6e2d657863657074696f6e2e737667)](https://packagist.org/packages/pnz/json-exception)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/d64a614b26fd7ff98e4a91919b8908ec3c48d37ec20bd013efbdc26ae9c38c97/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f74686550616e7a2f6a736f6e2d657863657074696f6e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/thePanz/json-exception)

Usage
-----

[](#usage)

This library provides `Json::decode()` and `Json::encode()` implementations throwing `\JsonException` on errors.

To use this library:

- install the library by using composer: `composer require pnz/json-exception`
- replace the usage of `json_decode()` with `Json::decode()`
- replace the usage of `json_encode()` with `Json::encode()`
- catch the `\JsonException` eventually thrown by the functions

Example: Old code

```
 $data = json_decode($jsonString, ...);
 if (ERROR_NONE !== json_last_error()) {
     // handle the error: thown a custom exception, or return
     // $error = json_last_error_msg();
     // $errorCode = json_last_error();
 }
```

new code:

```
try {
    $data = Json::decode($jsonString, ...);
} catch(\JsonException $e) {
   // Handle the exception
}
```

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

[](#development)

To run the PHP coding-styles checks (`php-cs-fixer` and `phpstan`) run the `make phpcs` command to:

- download the `php-cs-fixer` tool in `tools/` (if not present)
- download the `phpstan` tool in `tools/` (if not present)
- Run `php-cs-fixer` on the source code
- Run `phpstan` on the source code

To run the tests, use `make tests` to

- download `phpunit` tool in `tools/` if not present
- run `phpunit` tests

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~507 days

Total

3

Last Release

1735d ago

Major Versions

v0.1.0 → v1.0.02020-05-26

PHP version history (2 changes)v0.1.0PHP ^7.0

v1.0.1PHP ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a788c96bbcf89371ff0c614ad9f1655363369cb8e17ffd7afbebf046da6dad8?d=identicon)[thepanz](/maintainers/thepanz)

---

Top Contributors

[![thePanz](https://avatars.githubusercontent.com/u/226021?v=4)](https://github.com/thePanz "thePanz (4 commits)")[![Neur0toxine](https://avatars.githubusercontent.com/u/24733820?v=4)](https://github.com/Neur0toxine "Neur0toxine (3 commits)")

---

Tags

json

### Embed Badge

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

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

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k316.9M612](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30422.2M45](/packages/colinodell-json5)[clue/ndjson-react

Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.

15467.7M16](/packages/clue-ndjson-react)

PHPackages © 2026

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