Skip to content

Repository files navigation

JSON

Current versionSupported PHP versionTestsDiscordSponsor

A simple helper to decode and encode JSON, including from files.

Usage

useBeste\Json;
useUnexpectedValueException;
$object = Json::decode('{"key": "value"}');
$array = Json::decode('{"key": "value"}', $forceArray = true);
$object = Json::decodeFile('/path/to/file.json');
$json = Json::encode($object);
$prettyJson = Json::pretty($object);
// When something goes wring while decoding/encoding,// an `UnexpectedValueException` is throwntry {
Json::decode('{]');
} catch (UnexpectedValueException$e) {
// Handle error
}

Installation

composer require beste/json

Running tests

composer test

About

A simple JSON helper to decode and encode JSON

Topics

Resources

Security policy

Stars

43 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages