tc / json
A JSON encode/decode helper with easier error handling for PHP
Installs: 26
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/tc/json
Requires
- php: >=5.5.0
This package is not auto-updated.
Last update: 2025-10-12 06:58:16 UTC
README
A JSON encode/decode helper with easier error handling for PHP
Installation
composer require tc/json
Usage
<?php use Tc\Json\Json; use Tc\Json\JsonException; $data = [ 'foo' => 'bar', ]; $jsonString = Json::encode($data); // {"foo": "bar"} $jsonDataObject = Json::decode($jsonString); // ( [foo] => bar ) $jsonDataArray = Json::decode($jsonString, true ); // ['foo' => 'bar'] $jsonData = Json::decode($jsonString, true); // ['foo' => 'bar'] try { Json::decode('{"foo"'); // invalid json string } catch(JsonException $e) { echo $e->getMessage(); // description of error }
License
Tc Json is licensed with the MIT license.
See LICENSE for more details.