xoubaman / json
A simple JSON wrapper
0.1
2020-05-16 17:07 UTC
Requires
- php: ^7.3
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.1
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2026-02-17 07:13:42 UTC
README
A simple JSON wrapper class.
Features:
- Encode arrays|objects
- Decode JSON strings
- Validate JSON strings
- Throw exceptions on failure
Nothing else. As said, it is simple.
Usage
Json::encode($input): string: encodes into JSONJson::decode(string $json): array: decodes a JSON into an arrayJson::fromString(string $json): new Json instance$json->isValid(): bool: whether the provided JSON is valid or not$json->input(): string: the input used for instantiation$json->error(): string: the error description, empty if no error$json->errorCode(): int: the error code, JSON_ERROR_NONE if no error$json->asArray(): array: the input decoded, throws aRuntimeExceptionif not a valid JSON