PHPackages                             codekandis/json-error-handler - 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. codekandis/json-error-handler

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

codekandis/json-error-handler
=============================

`codekandis/json-error-handler` is a library to handle JSON errors in an object oriented way.

2.1.0(5y ago)07291MITPHPPHP ^7.4

Since Oct 19Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/codekandis/json-error-handler)[ Packagist](https://packagist.org/packages/codekandis/json-error-handler)[ RSS](/packages/codekandis-json-error-handler/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)Dependencies (4)Versions (6)Used By (1)

codekandis/json-error-handler
=============================

[](#codekandisjson-error-handler)

[![Version](https://camo.githubusercontent.com/55f30def4a68344c0de905e67851fe21552f126e98f7c99bbe794e47be861c23/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d332e302e302d626c75652e737667)](./CHANGELOG.md)[![License](https://camo.githubusercontent.com/07a7d0169027aac6d7a0bfa8964dfef5fbc40d5a2075cabb3d8bc67e17be3451/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d79656c6c6f772e737667)](./LICENSE)[![Minimum PHP Version](https://camo.githubusercontent.com/ec21f169d70b69344c67d6f18fa1a24d20476d2f0cd680e8c4a1534c22f34e5f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3838393242462e737667)](https://php.net)[![Code Coverage](https://camo.githubusercontent.com/af813ae002de8e31bfd234a3d5eab4fe1963ed998df54d1f3c5e3e1fe334f7d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d677265656e2e737667)](https://camo.githubusercontent.com/af813ae002de8e31bfd234a3d5eab4fe1963ed998df54d1f3c5e3e1fe334f7d6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d677265656e2e737667)

With the JSON error handler you will be able to catch exceptions representing the last occurred JSON error containing the native error codes and error messages of PHP's `JSON` package.

Index
-----

[](#index)

- [Installation](#installation)
- [How to use](#how-to-use)

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

[](#installation)

Install the latest version with

```
$ composer require codekandis/json-error-handler
```

How to use
----------

[](#how-to-use)

The following example throws a [`JsonException`](./src/JsonException.php) with the error code of [`JsonErrorCodes::SYNTAX`](./src/JsonErrorCodes.php) with the message of [`JsonErrorMessage::SYNTAX`](./src/JsonErrorMessages.php).

```
json_decode( '{"foobar":}' );
( new JsonErrorHandler() )->handle();
```

The error codes in [`JsonErrorCodes`](./src/JsonErrorCodes.php) are equal to [PHP's native `JSON_ERROR`](https://www.php.net/manual/en/function.json-last-error.php#refsect1-function.json-last-error-returnvalues) constants. The error messages in [`JsonErrorMessages`](./src/JsonErrorMessages.php) are equal to [PHP's error messages of `json_last_error_msg()`](https://www.php.net/manual/en/function.json-last-error-msg.php).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance41

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~152 days

Total

4

Last Release

1983d ago

Major Versions

1.0.0 → 2.0.02021-01-16

PHP version history (2 changes)1.0.0PHP ^7.3

2.0.0PHP ^7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31327217?v=4)[Christian Ramelow](/maintainers/codekandis)[@codekandis](https://github.com/codekandis)

---

Top Contributors

[![codekandis](https://avatars.githubusercontent.com/u/31327217?v=4)](https://github.com/codekandis "codekandis (51 commits)")

---

Tags

errorhandlerjsonphpphpjsonerrorhandlerjson error handler

### Embed Badge

![Health badge](/badges/codekandis-json-error-handler/health.svg)

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

###  Alternatives

[adhocore/json-fixer

Fix/repair truncated JSON data

51569.3k2](/packages/adhocore-json-fixer)[blancks/fast-jsonpatch-php

Class designed to efficiently handle JSON Patch operations in accordance with the RFC 6902 specification

397.9k](/packages/blancks-fast-jsonpatch-php)[josantonius/json

PHP simple library for managing Json files.

1722.4k10](/packages/josantonius-json)

PHPackages © 2026

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