toolkit
Json
JSON encode and decode.
Json::
Phlat\Toolkit\Json
4 methods
- decode Decodes JSON into arrays; throws on invalid input.
- decodeArray Decodes JSON to an array.
- encode Encodes as JSON with unescaped slashes, pretty-printed on request; throws on failure.
- valid Whether the string is valid JSON.
Methods
Json::decode(string $json): mixed
Decodes JSON into arrays; throws on invalid input.
Parameters (1)
| $json | string |
Returns mixed
phlat/src/Toolkit/Json.php:22
Json::decodeArray(string $json, array $default = []): array
Decodes JSON to an array.
Returns $default for invalid JSON or a valid-but-non-array result.
Parameters (2)
| $json | string | |
| $default | array = [] |
Returns array
phlat/src/Toolkit/Json.php:39
Json::encode(mixed $data, bool $pretty = false): string
Encodes as JSON with unescaped slashes, pretty-printed on request; throws on failure.
Parameters (2)
| $data | mixed | |
| $pretty | bool = false |
Returns string
phlat/src/Toolkit/Json.php:15
Json::valid(string $json): bool
Whether the string is valid JSON.
Parameters (1)
| $json | string |
Returns bool
phlat/src/Toolkit/Json.php:28