final class Json

JSON encoder and decoder.

Constants

deprecated FORCE_ARRAY

deprecated PRETTY

deprecated ESCAPE_UNICODE

Methods

static string
encode(mixed $value, bool|int $pretty = false, bool $asciiSafe = false, bool $htmlSafe = false, bool $forceObjects = false)

Converts value to JSON format. Use $pretty for easier reading and clarity, $asciiSafe for ASCII output and $htmlSafe for HTML escaping, $forceObjects enforces the encoding of non-associateve arrays as objects.

static mixed
decode(string $json, bool|int $forceArrays = false)

Parses JSON to PHP value. The $forceArrays enforces the decoding of objects as arrays.

Details

at line 37
static string encode(mixed $value, bool|int $pretty = false, bool $asciiSafe = false, bool $htmlSafe = false, bool $forceObjects = false)

Converts value to JSON format. Use $pretty for easier reading and clarity, $asciiSafe for ASCII output and $htmlSafe for HTML escaping, $forceObjects enforces the encoding of non-associateve arrays as objects.

Parameters

mixed $value
bool|int $pretty
bool $asciiSafe
bool $htmlSafe
bool $forceObjects

Return Value

string

Exceptions

JsonException

at line 70
static mixed decode(string $json, bool|int $forceArrays = false)

Parses JSON to PHP value. The $forceArrays enforces the decoding of objects as arrays.

Parameters

string $json
bool|int $forceArrays

Return Value

mixed

Exceptions

JsonException

Traits

Static class.