inerciacreativa / json
PHP class for working with JSON objects
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/inerciacreativa/json
Requires
- php: >=8.0
- ext-simplexml: *
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2025-10-04 20:51:38 UTC
README
The package provides methods to encode and decode JSON.
- It has sensible defaults, so you don't have to specify flags all the time.
- It has handy method to encode for HTML safely.
- It throws
\IC\Json\Exception\JsonEncodeExceptionwhen encoding fails. - It throws
\IC\Json\Exception\JsonDecodeExceptionwhen decoding fails. - It handles
\JsonSerializable,\DateTimeInterface, and\SimpleXMLElementwell.
Requirements
- PHP 8.0 or higher.
SimpleXMLPHP extension.
Installation
The package could be installed with composer:
composer require inerciacreativa/json --prefer-dist
General usage
Encoding:
use \IC\Json\Json; $data = ['name' => 'Jose', 'team' => 'Inercia Creativa']; $json = Json::encode($data);
Encoding for HTML:
use \IC\Json\Json; $data = ['name' => 'Jose', 'team' => 'Inercia Creativa']; $json = Json::htmlEncode($data);
Decoding:
use \IC\Json\Json; $json = '{"name":"Jose","team":"Inercia Creativa"}'; $data = Json::decode($json);
Testing
Unit testing
The package is tested with PHPUnit. To run tests:
composer phpunit
Static analysis
The code is statically analyzed with PHPStan. To run static analysis:
composer phpstan
License
The IC JSON is free software. It is released under the terms of the MIT License.
Please see LICENSE for more information.
Maintained by Inercia Creativa.