library json-object
Treat JSON as objects in PHP
kapitanluffy/json-object
Treat JSON as objects in PHP
- Thursday, April 26, 2018
- by kapitanluffy
- Repository
- 1 Watchers
- 1 Stars
- 0 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
PHP JSON Objects
Treat JSON as objects in PHP instead of strings., (*1)
Install
composer require kapitanluffy/json-object
Usage
$json = new JsonObject($data);
// encoding to json
$encoded = json_encode($json);
$encoded = $json->encode();
$encoded = (string) $json;
// decoding to data
$decoded = JsonObject::decode($json);
// set options
$json->options(JSON_NUMERIC_CHECK)->encode();
// throw a JsonException on error
$json->withErrors(true)->encode();
// check if the current instance throws an error
$json->isErrorThrown();
// returns the last occurred JsonException
JsonObject::getError();
Note that methods options
and withErrors
returns a new instance rather than modifying the current JsonObject instance., (*2)
dev-master
9999999-dev
Treat JSON as objects in PHP
Sources
Download
MPL-2.0
The Requires