PHPackages                             mihasicehcek/json\_parser - 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. mihasicehcek/json\_parser

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

mihasicehcek/json\_parser
=========================

Simple wrapper over json\_decode/json\_encode php functions. Throws exceptions when decoding/encoding fails

v1.0.2(9y ago)05.7k1MITPHPPHP &gt;=5.2.0

Since Jan 18Pushed 9y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (4)Used By (1)

JsonParser
==========

[](#jsonparser)

[![Latest Stable Version](https://camo.githubusercontent.com/ae82ae30ec2098bce5cb9ca46d3c858a037b9d37afb9260bf360f320d5b394c8/68747470733a2f2f706f7365722e707567782e6f72672f6d696861736963656863656b2f6a736f6e5f7061727365722f76657273696f6e)](https://packagist.org/packages/mihasicehcek/php_json_rpc_2_server)[![Total Downloads](https://camo.githubusercontent.com/5304c612e22be5a6fe8f556168049f36d879ebf9f9161fe0df4bd3fa9926608d/68747470733a2f2f706f7365722e707567782e6f72672f6d696861736963656863656b2f6a736f6e5f7061727365722f646f776e6c6f616473)](https://packagist.org/packages/mihasicehcek/php_json_rpc_2_server)[![License](https://camo.githubusercontent.com/6af12821d1ee5ad2343f7c80b68d63cfe30b0db8986f090a4e98bc3e06361e22/68747470733a2f2f706f7365722e707567782e6f72672f6d696861736963656863656b2f6a736f6e5f7061727365722f6c6963656e7365)](https://packagist.org/packages/mihasicehcek/php_json_rpc_2_server)

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

[](#installation)

### With Composer

[](#with-composer)

```
$ composer require mihasicehcek/json_parser

```

Simple Eample
-------------

[](#simple-eample)

Simple wrapper over json\_decode/json\_encode php functions. Throws exceptions when decoding/encoding fails.

```
try{
  $json = '{"integer":1';
  $result = \JsonParser\JsonParser::jsonDecode('{"integer":1');
}catch(\JsonParser\Exception $ex){
  print_r("Message: ".$ex->getMessage().", code: ".$ex->getCode()); //Message: Syntax error, code: 4
}

try{
  $a = new stdClass();
  $b = new stdClass();
  $a->b = $b;
  $b->a = $a;
  $result = \JsonParser\JsonParser::jsonEncode($a);
}catch(\JsonParser\Exception $ex){
  print_r("Message: ".$ex->getMessage().", code: ".$ex->getCode()); //Message: The object or array passed to json_encode include recursive references and cannot be encoded, code: 7
}
```

Library has two public methods \\JsonParser\\JsonParser::jsonDecode() for serialization and \\JsonParser\\JsonParser::jsonEncode() for deserialization. Signature of these method same as [json\_decode](http://php.net/manual/ru/function.json-decode.php "json_decode") and [json\_encode](http://php.net/manual/ru/function.json-encode.php "json_encode"). But unlike native function library throws exceptions when decoding/encoding went wrong. There are exceptions for each de/serialization error. Full list of error you can see at [json\_last\_error](http://php.net/manual/ru/function.json-last-error.php "json_last_error")

Exceptions
----------

[](#exceptions)

Library detects and throws such exceptions

- \\JsonParser\\SyntaxException - Syntax error.
- \\JsonParser\\ControlCharacterException - Control character error, possibly incorrectly encoded.
- \\JsonParser\\DepthException - The maximum stack depth has been exceeded.
- \\JsonParser\\InfOrNanException - The value passed to json\_encode() includes either NAN or INF.
- \\JsonParser\\InvalidPropertyNameException - A key starting with \\u0000 character was in the string passed to json\_decode() when decoding a JSON object into a PHP object.
- \\JsonParser\\RecursionException - The object or array passed to json\_encode include recursive references and cannot be encoded.
- \\JsonParser\\StateMismatchException - State mismatch (invalid or malformed JSON).
- \\JsonParser\\UnsupportedTypeException - A value of an unsupported type was given to json\_encode(), such as a resource.
- \\JsonParser\\Utf8Exception - Malformed UTF-8 characters, possibly incorrectly encoded.
- \\JsonParser\\Utf16Exception - Single unpaired UTF-16 surrogate in unicode escape contained in the JSON string passed to json\_encode().

All those exceptions extends base \\JsonParser\\Exception

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% 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 ~29 days

Total

3

Last Release

3344d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61639a0f0afc160acbf538c041d6411f1a18a3ea10193812e29d49354c3037a1?d=identicon)[mihasicehcek](/maintainers/mihasicehcek)

---

Top Contributors

[![mihasicehcek](https://avatars.githubusercontent.com/u/10881356?v=4)](https://github.com/mihasicehcek "mihasicehcek (17 commits)")[![Nguimjeu](https://avatars.githubusercontent.com/u/9998717?v=4)](https://github.com/Nguimjeu "Nguimjeu (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

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