Download the PHP package php-enspired/simple-json without Composer
On this page you can find all versions of the php package php-enspired/simple-json. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-enspired/simple-json
More information about php-enspired/simple-json
Files in php-enspired/simple-json
Package simple-json
Short Description Convenience wrapper for json encoding/decoding.
License GPL-3.0-only
Informations about the package simple-json
it's simple: json
Simple packages are focused on being straightforward, clean, concise solutions for common needs.
Json is a convenience wrapper for json encoding/decoding. Its main purpose is to set sane defaults and make managing encoding/decoding options easy.
dependencies
Requires php 7.3 or later.
installation
Recommended installation method is via Composer: simply composer require php-enspired/simple-json
.
basic usage
By default, objects are decoded as associative arrays and big integers are decoded as strings (rather than converting them to float).
When encoding data, big integers are encoded as strings, "zero" fractions are preserved (rather then encoding them as integers), and slashes and unicode characters are not escaped. To prevent unexpected/unpredictable results, objects will not be encoded unless they are stdClass
or implement JsonSerializable
.
Both encoding and decoding throw on error; this cannot be overridden.
Json defines some constants for sets of encode/decode options. As a convenience, these options are also settable via static factory methods.
ENCODE_ASCII
: default encoding options, but unsetsJSON_UNESCAPED_UNICODE
.ENCODE_HEX
: all of theJSON_HEX_*
options.ENCODE_HTML
: default encoding options, but unsetsJSON_UNESCAPED_SLASHES
.ENCODE_PRETTY
: default encoding options, and also setsJSON_PRETTY_PRINT
.
docs
- Getting Started (It's Simple)
- Constructor and Factory Methods
__construct()
::default()
::ascii()
::hex()
::html()
::pretty()
- Encoding and Decoding
encode()
decode()
- Managing Options
setOptions()
- Handling Errors
JsonException
InvalidArgumentException
contributing or getting help
I'm on Freenode at #php-enspired
, or open an issue on github. Feedback is welcomed.