PHPackages                             cse/helpers-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. [Framework](/categories/framework)
4. /
5. cse/helpers-json

ActiveLibrary[Framework](/categories/framework)

cse/helpers-json
================

The helpers allows you to JSON processing. Encode, decode, check error, throw exception - all this is available in this library.

1.1.2(7y ago)795121MITPHPPHP &gt;=7.1

Since Jan 19Pushed 7y ago3 watchersCompare

[ Source](https://github.com/cs-eliseev/helpers-json)[ Packagist](https://packagist.org/packages/cse/helpers-json)[ Docs](https://github.com/cs-eliseev/helpers-json)[ RSS](/packages/cse-helpers-json/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (13)Used By (1)

English | [Русский](https://github.com/cs-eliseev/helpers-json/blob/master/README.ru_RU.md)

JSON CSE HELPERS
================

[](#json-cse-helpers)

[![Travis (.org)](https://camo.githubusercontent.com/7a50e9168943e88f0e48bdd61290c11aa41ff32fe4acfb6783f4ae29ccd4083a/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f63732d656c69736565762f68656c706572732d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/cs-eliseev/helpers-json)[![Codecov](https://camo.githubusercontent.com/67706fdc94b9ae33a5ecae8c3af00ad3b651669308b5f1df2c696aee2494360a/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f63732d656c69736565762f68656c706572732d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/cs-eliseev/helpers-json)[![Scrutinizer code quality](https://camo.githubusercontent.com/a8f2449ee9066c6809c3c355a4c970559317b81ba1fe61fbfebe27cc8e44e84d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f63732d656c69736565762f68656c706572732d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/cs-eliseev/helpers-json/?branch=master)

[![Packagist](https://camo.githubusercontent.com/8e90be746a10f616bd6cf02deb213c59f756e87cea473369f2d85109211846d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6373652f68656c706572732d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cse/helpers-json)[![Minimum PHP Version](https://camo.githubusercontent.com/dcd4b4aec2c1709157fa6a2c050f709d75cde9552a79cfff0b70a97fad7281ae/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e312d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cse/helpers-json)[![Packagist](https://camo.githubusercontent.com/ff87f2165e667ae2dcc0b75ea11c7cd4b05d225b7786740ac64c40b44aae5d04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6373652f68656c706572732d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/cs-eliseev/helpers-json/blob/master/LICENSE.md)[![GitHub repo size](https://camo.githubusercontent.com/e18b77ba5c380bd87a998e85a96063c9a3a68bee634cc8ccf977ccd2bc263fe3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f63732d656c69736565762f68656c706572732d6a736f6e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/cs-eliseev/helpers-json/archive/master.zip)

The helpers allows you to JSON processing. Encode, decode, check error, throw exception - all this is available in this library.

Project repository:

**DEMO**

```
$json = [
    '{"example": 12345}',   // success
    "{'example': 12345}",   // Syntax error
    '{"example": 12345}',   // success
];

foreach ($json as $item) {
    try {
        Json::decode($item);
        Json::errorToException();
        var_dump('success');
    } catch (CSEHelpersJsonException $e) {
        var_dump($e->getMessage());
    }
}
```

---

Introduction
------------

[](#introduction)

[CSE HELPERS](https://github.com/cs-eliseev/helpers/blob/master/README.md) is a collection of several libraries with simple functions written in PHP for people.

Despite using PHP as the main programming language for the Internet, its functions are not enough. JSON CSE HELPERS used method: encode, decode, check error, throw exception.

[CSE HELPERS](https://github.com/cs-eliseev/helpers/blob/master/README.md) was created for the rapid development of web applications.

**CSE Helpers project:**

- [Array CSE helpers](https://github.com/cs-eliseev/helpers-arrays)
- [Cookie CSE helpers](https://github.com/cs-eliseev/helpers-cookie)
- [Date CSE helpers](https://github.com/cs-eliseev/helpers-date)
- [Email CSE helpers](https://github.com/cs-eliseev/helpers-email)
- [IP CSE helpers](https://github.com/cs-eliseev/helpers-ip)
- [Json CSE helpers](https://github.com/cs-eliseev/helpers-json)
- [Math Converter CSE helpers](https://github.com/cs-eliseev/helpers-math-converter)
- [Phone CSE helpers](https://github.com/cs-eliseev/helpers-phone)
- [Request CSE helpers](https://github.com/cs-eliseev/helpers-request)
- [Session CSE helpers](https://github.com/cs-eliseev/helpers-session)
- [Word CSE helpers](https://github.com/cs-eliseev/helpers-word)

Below you will find some information on how to init library and perform common commands.

Install
-------

[](#install)

You can find the most recent version of this project [here](https://github.com/cs-eliseev/helpers-json).

### Composer

[](#composer)

Execute the following command to get the latest version of the package:

```
composer require cse/helpers-json
```

Or file composer.json should include the following contents:

```
{
    "require": {
        "cse/helpers-json": "*"
    }
}
```

### Git

[](#git)

Clone this repository locally:

```
git clone https://github.com/cs-eliseev/helpers-json.git
```

### Download

[](#download)

[Download the latest release here](https://github.com/cs-eliseev/helpers-json/archive/master.zip).

Usage
-----

[](#usage)

The class consists of static methods that are conveniently used in any project. See example [examples-json.php](https://github.com/cs-eliseev/helpers-json/blob/master/examples/examples-json.php).

**JSON ENCODE**

Example:

```
Json::encode(['example' => 12345]);
// {"example": 12345}
```

Set Check Exception:

```
Json::setCheckException();
Json::encode([urldecode('bad utf string %C4_')]);
// Exception: Malformed UTF-8 characters, possibly incorrectly encoded
```

**JSON Pretty Print**

Example:

```
Json::prettyPrint(['example' => 12345, 'example2' => 56789]);
// {
//    "example": 12345,
//    "example": 56789
// }
```

Set Check Exception:

```
Json::setCheckException();
Json::prettyPrint([urldecode('bad utf string %C4_')]);
// Exception: Malformed UTF-8 characters, possibly incorrectly encoded
```

**JSON DECODE**

Example:

```
Json::decode('{"example": 12345}');
// ['example' => 12345]
```

Set Check Exception:

```
Json::setCheckException();
Json::decode("{'example': 12345}");
// Syntax error
```

**GET JSON data to key**

Example:

```
Json::get('{"example": 12345}', 'example');
// 12345
```

Set default data:

```
Json::get('{"example": 12345}', 'example2', 56789);
// 56789
```

Set Check Exception:

```
Json::setCheckException();
Json::get("{'example': 12345}", 'example');
// Syntax error
```

**SET JSON data**

Example:

```
Json::set('{"example": 12345}', 'example2', 56789);
// {"example": 12345, "example2": 56789}
```

Change value:

```
Json::set('{"example": 12345}', 'example', 56789);
// {"example": 56789}
```

Set Check Exception:

```
Json::setCheckException();
Json::set("{'example': 12345}", 'example2', 56789);
// Syntax error
```

**SET ARRAY JSON**

Example:

```
Json::setArray('{"example": 12345}', ['example2' => 56789]);
// {"example": 12345, "example2": 56789}
```

Change value:

```
Json::setArray('{"example": 12345}', ['example' => 56789]);
// {"example": 56789}
```

Set Check Exception:

```
Json::setCheckException();
Json::setArray("{'example': 12345}", ['example2' => 56789]);
// Syntax error
```

**Check error last json transform**

Example:

```
Json::decode('{"example": 12345}');
Json::isNoteError();
// true
Json::decode("{'example': 12345}");
Json::isNoteError();
// false
```

**Get error**

Example:

```
Json::decode('{"example": 12345}');
Json::getErrorMsg();
// NULL
Json::decode("{'example': 12345}");
Json::getErrorMsg();
// Syntax error
```

Add msg:

```
Json::decode("{'example': 12345}");
Json::getErrorMsg('- Example');
// Syntax error - Example
```

**Error to exception**

Example:

```
try {
    Json::decode("{'example': 12345}");
    Json::errorToException();
} catch (CSEHelpersJsonException $e) {
    var_dump($e->getMessage());
}
// Syntax error
```

Add msg:

```
try {
    Json::decode("{'example': 12345}");
    Json::errorToException('(JSON)');
} catch (CSEHelpersJsonException $e) {
    var_dump($e->getMessage());
}
// Syntax error (JSON)
```

Exception instance:

```
try {
    Json::decode("{'example': 12345}");
    Json::errorToException('(JSON)');
} catch (CseExceptions $e) {
    var_dump($e->getMessage());
}
// Syntax error (JSON)
```

**Set check exception**

Example:

```
class Default
{
    public function example(): void
    {
        Json::encode('{"example": 12345}');
    }
}

class ExceptionTrue
{
    public function example(): void
    {
        Json::setCheckException();
        Json::encode("{'example': 12345}");
    }
}

class ExceptionFalse
{
    public function example(): void
    {
        Json::setCheckException(false);
        Json::encode("{'example': 12345}");
    }
}

$default = new Default();
$e_true = new ExceptionTrue();
$e_false = new ExceptionFalse();

try {
    $default->example();
} catch (CSEHelpersJsonException $e) {
    var_dump($e->getMessage());
}

try {
    $e_true->example();
} catch (CSEHelpersJsonException $e) {
    var_dump($e->getMessage());
}
// Syntax error

try {
    $default->example();
} catch (CSEHelpersJsonException $e) {
    var_dump($e->getMessage());
}
// Syntax error

try {
    $e_false->example();
} catch (CSEHelpersJsonException $e) {
    var_dump($e->getMessage());
}

try {
    $default->example();
} catch (CSEHelpersJsonException $e) {
    var_dump($e->getMessage());
}
```

Testing &amp; Code Coverage
---------------------------

[](#testing--code-coverage)

PHPUnit is used for unit testing. Unit tests ensure that class and methods does exactly what it is meant to do.

General PHPUnit documentation can be found at .

To run the PHPUnit unit tests, execute:

```
phpunit PATH/TO/PROJECT/tests/
```

If you want code coverage reports, use the following:

```
phpunit --coverage-html ./report PATH/TO/PROJECT/tests/
```

Used PHPUnit default config:

```
phpunit --configuration PATH/TO/PROJECT/phpunit.xml
```

Donating
--------

[](#donating)

You can support this project [here](https://www.paypal.me/cseliseev/10usd). You can also help out by contributing to the project, or reporting bugs. Even voicing your suggestions for features is great. Anything to help is much appreciated.

License
-------

[](#license)

The JSON CSE HELPERS is open-source PHP library licensed under the MIT license. Please see [License File](https://github.com/cs-eliseev/helpers-json/blob/master/LICENSE.md) for more information.

---

> GitHub [@cs-eliseev](https://github.com/cs-eliseev)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

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 ~9 days

Total

12

Last Release

2566d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3b9e49d0ce3fd71c8eb31b7c14e48373dbb415a9d16950ce52d23bf89b2ae26?d=identicon)[ak\_eliseev](/maintainers/ak_eliseev)

---

Top Contributors

[![cs-eliseev](https://avatars.githubusercontent.com/u/24221291?v=4)](https://github.com/cs-eliseev "cs-eliseev (101 commits)")

---

Tags

collectioncollectionscseframeworkhelperhelpersjsonlibraryphptooltoolsutilitiesutilityutilsjsonframeworkhelperutilityhelperslibrarytoolcollectioncollectionstoolsutilsutilitiescse

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[cse/helpers-session

The helpers allows you to easily manage session data. START, SET, GET DELETE, HAS method session - all this is available in this library.

102.6k3](/packages/cse-helpers-session)[jbzoo/utils

Collection of PHP functions, mini classes and snippets for everyday developer's routine life.

8321.5M36](/packages/jbzoo-utils)[dragon-code/support

Support package is a collection of helpers and tools for any project.

238.7M101](/packages/dragon-code-support)[hprose/hprose-swoole

Hprose asynchronous client &amp; standalone server based on swoole

17928.9k9](/packages/hprose-hprose-swoole)

PHPackages © 2026

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