8ctopus / relaxed-json
Tired of JSON's super strict syntax? Then relaxed JSON if for you.
1.0.3
2024-11-26 09:51 UTC
Requires
- php: >=7.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- nunomaduro/collision: ^5.0|^6.0
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9|^10
This package is auto-updated.
Last update: 2024-11-26 09:53:01 UTC
README
Tired of JSON's super strict syntax? Then relaxed JSON if for you.
features
- supports comments in all forms
// my comment
,/* my comment */
- ignores trailing commas at the end of an array or object
- throws an Exception when the json is invalid
- zero dependencies
install
composer require 8ctopus/relaxed-json
usage
use Oct8pus\RelaxedJson; $json = <<<JSON { // maximum requests per hour "throttleThreshold": 300, } JSON; var_dump(RelaxedJson::decode($json, true));
array(1) { 'name' => string(20) "8ctopus/relaxed-json" }
exceptions
$json = <<<JSON { "throttleThreshold" => 300, } JSON; // throws RelaxedJsonException Syntax error RelaxedJson::decode($json, true);
credits
This library is are repack with improvements of the original work from https://github.com/etconsilium/php-json-fix
tests
composer test
clean code
composer fix
composer fix-risky