ortnit / json
wrapper for json functions
v1.0.0
2022-01-30 05:49 UTC
Requires
- php: >=7.4
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-xml: *
- ext-xmlwriter: *
Requires (Dev)
- overtrue/phplint: ^4.0
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: 3.*
README
Readme
Helper for php functions json_enconde() and json_decode(). JSON_THROW_ON_ERROR
will always be applied,
so every error will be thrown as exception. Other flags can also be set, the configuration is static.
Per default Json::decode()
will create assoc arrays, not objects.
Json::decode(string $json, bool $assoc = true)
will decode json and return the decoded structure
Json::encode(mixed $value)
will encode the value and return the json string
Json::setOptions(...$options)
allow you to set the JSON flags from the php documentation,
https://www.php.net/manual/en/json.constants.php. Function will overwrite all flags.
Json::getOptions()
will return the current options set