![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/medad.corals.io/vendor/beste/json/ |
# JSON [](https://packagist.org/packages/beste/json) [](https://packagist.org/packages/beste/json) [](https://github.com/beste/json-php/actions) [](https://discord.gg/Yacm7unBsr) [](https://github.com/sponsors/jeromegamez) A simple helper to decode and encode JSON, including from files. ## Usage ```php use Beste\Json; use UnexpectedValueException; $object = Json::decode('{"key": "value"}'); $array = Json::decode('{"key": "value"}', $forceArray = true); $object = Json::decodeFile('/path/to/file.json'); $json = Json::encode($object); $prettyJson = Json::pretty($object); // When something goes wring while decoding/encoding, // an `UnexpectedValueException` is thrown try { Json::decode('{]'); } catch (UnexpectedValueException $e) { // Handle error } ``` ## Installation ```shell composer require beste/json ``` ## Running tests ```shell composer run tests ```