8ctopus / relaxed-json
Tired of JSON's super strict syntax? Then relaxed JSON if for you.
Installs: 52
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/8ctopus/relaxed-json
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: 2025-09-24 06:44:48 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