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

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

royalcms/wrappers-php-json
==========================

The Most Useful Wrappers For PHP Functions

v2.0.0(5y ago)01231MITPHPPHP ^7.2

Since May 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/royalcms/wrappers-php-json)[ Packagist](https://packagist.org/packages/royalcms/wrappers-php-json)[ RSS](/packages/royalcms-wrappers-php-json/feed)WikiDiscussions main Synced 1w ago

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

 [![logo](https://camo.githubusercontent.com/421f0771cbca81a5ce4ddb23ad8294af7ae5c51dbd19b00f96d19286b2efb317/68747470733a2f2f6873746f2e6f72672f776562742f30762f71622f30702f30767162307070366e74797964386d62646b6b6a3077736c6c776f2e706e67)](https://camo.githubusercontent.com/421f0771cbca81a5ce4ddb23ad8294af7ae5c51dbd19b00f96d19286b2efb317/68747470733a2f2f6873746f2e6f72672f776562742f30762f71622f30702f30767162307070366e74797964386d62646b6b6a3077736c6c776f2e706e67)

The Most Useful Wrappers For PHP Functions
==========================================

[](#the-most-useful-wrappers-for-php-functions)

[![Version](https://camo.githubusercontent.com/a9690bf6352e500e51c7eafe17e766d2d892c2f78ab2ca3e2d3c105494a0bbd4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746172616d70616d70616d2f77726170706572732d7068702e7376673f6d61784167653d313830)](https://packagist.org/packages/tarampampam/wrappers-php)[![Version](https://camo.githubusercontent.com/bad2b043fe46ca4bad8b17acb632581c99941b8707a7168b669e54d4c5857eec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746172616d70616d70616d2f77726170706572732d7068702e7376673f6c6f6e6743616368653d74727565)](https://packagist.org/packages/tarampampam/wrappers-php)[![Build Status](https://camo.githubusercontent.com/3b21857dc55d7c5067e32fb6ffe69b5088ae5f7b96f92ba2f0a70a51966c21b9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f746172616d70616d70616d2f77726170706572732d7068702f74657374733f6d61784167653d3330)](https://github.com/tarampampam/wrappers-php/actions)[![Coverage](https://camo.githubusercontent.com/642b8f26316a6a7081bf0c32c58b47d414d32a8614c9ad83fb8a2bb3efa0da41/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746172616d70616d70616d2f77726170706572732d7068702f6d61737465722e7376673f6d61784167653d3630)](https://codecov.io/gh/tarampampam/wrappers-php/)[![Downloads count](https://camo.githubusercontent.com/ba545cefdf0715fb1668b62ecd2aa7d5a3e7cc3951bb34de2c1555ac3415a5d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746172616d70616d70616d2f77726170706572732d7068702e7376673f6d61784167653d313830)](https://packagist.org/packages/tarampampam/wrappers-php)[![License](https://camo.githubusercontent.com/b1a1b8cb826db96a6af89c3c328c2a892a3b9d7ab1b4b78a22b8637050adb475/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746172616d70616d70616d2f77726170706572732d7068702e7376673f6c6f6e6743616368653d74727565)](https://github.com/tarampampam/wrappers-php/blob/master/LICENSE)

This package contains most useful wrappers for native PHP functions.

Install
-------

[](#install)

Require this package with composer using the following command:

```
$ composer require royalcms/wrappers-php-json "^2.0"
```

> Installed `composer` is required ([how to install composer](https://getcomposer.org/download/)).

> You need to fix the major version of package.

Usage
-----

[](#usage)

### [`\Tarampampam\Wrappers\Json`](./src/Json.php)

[](#tarampampamwrappersjson)

This wrapper was wrote for throwing exceptions (`JsonEncodeDecodeException`) on any tries to work with wrong json string or converting wrong object into json string.

Also method `::decode(...)` by default returns associated array instead object (`$assoc = true`).

Examples:

```
