PHPackages                             ksmz/json - 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. ksmz/json

AbandonedArchivedLibrary

ksmz/json
=========

JSON encode/decode wrapper with catchable exceptions

v0.1(7y ago)0183BSD-2-ClausePHPPHP &gt;=7.1

Since Jun 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/matical/json)[ Packagist](https://packagist.org/packages/ksmz/json)[ RSS](/packages/ksmz-json/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

json
----

[](#json)

[![Build Status](https://camo.githubusercontent.com/2ee42aa3097d841b39c6ce56386854ef84b978cb4bab7bdaf121d101f87d50ed/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d61746963616c2f6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/matical/json)[![Coveralls](https://camo.githubusercontent.com/9e058d77c69942dfa423713b429dce2e0df1ae4f82b2b1ffa42cdfd2f7fa471d/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6d61746963616c2f6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/matical/json)[![StyleCI](https://camo.githubusercontent.com/44d7e549ec5a07f7fbe613add1f6f01a05371a8e41b5a3dbdc6d7c2b87302897/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3133373332343031352f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/137324015)

A json\_encode/decode wrapper with specific, catchable exceptions.

### Installation

[](#installation)

`composer require ksmz/json`

### Basic Usage

[](#basic-usage)

```
use ksmz\json\Json;

Json::encode(['foo' => 'bar']);
```

### Exceptions

[](#exceptions)

All exceptions extend from `ksmz\json\Exceptions\JsonException`.

```
try {
    Json::encode(...);
} catch (RecursionException $exception) {
    // Specific exception
} catch (JsonException $exception) {
    // All possible exceptions
}
```

Error codes and messages can be retrieved from the corresponding exception (`$e->getMessage()`/`$e->getCode()`). Codes correspond to their respective error [constants](https://secure.php.net/manual/en/function.json-last-error.php).

For messages, exceptions with use messages identical to what `json_last_error_msg()` might return. Check out the [php-src](https://github.com/php/php-src/blob/master/ext/json/json.c#L215) for examples.

### Available Exceptions

[](#available-exceptions)

```
public static $errors = [
    JSON_ERROR_DEPTH                 => DepthException::class,
    JSON_ERROR_STATE_MISMATCH        => InvalidJsonException::class,
    JSON_ERROR_CTRL_CHAR             => ControlCharacterException::class,
    JSON_ERROR_SYNTAX                => SyntaxException::class,
    JSON_ERROR_UTF8                  => Utf8Exception::class,
    JSON_ERROR_UTF16                 => Utf16Exception::class,
    JSON_ERROR_RECURSION             => RecursionException::class,
    JSON_ERROR_INF_OR_NAN            => InfOrNanException::class,
    JSON_ERROR_UNSUPPORTED_TYPE      => UnsupportedTypeException::class,
    JSON_ERROR_INVALID_PROPERTY_NAME => InvalidPropertyNameException::class,
];
```

Some exceptions are self explantory, and some are a little vague. Check out the [tests](https://github.com/matical/json/blob/master/tests/JsonTest.php) for some examples. All exception tests use the same "inputs" as what PHP internally uses to test ext-json.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2895d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a4606e6650e58add8c0acd4eef7db84d94b29dca2f657efc3e82a74ad3731199?d=identicon)[amatsuka](/maintainers/amatsuka)

---

Top Contributors

[![matical](https://avatars.githubusercontent.com/u/15844155?v=4)](https://github.com/matical "matical (6 commits)")

---

Tags

jsonphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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