xoubaman / json
A simple JSON wrapper
Installs: 5 019
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/xoubaman/json
Requires
- php: ^7.3
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^9.1
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2025-11-17 06:33:46 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