final class Json

JSON encoder and decoder.

Constants

FORCE_ARRAY

PRETTY

ESCAPE_UNICODE

Methods

static string
encode(mixed $value, bool|int $pretty = false, bool $escapeUnicode = false)

Converts value to JSON format. Use $pretty for easier reading and clarity and $escapeUnicode for ASCII output.

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

Parses JSON to PHP value. Parameter $forceArray forces an array instead of an object as the return value.

Details

at line 31
static string encode(mixed $value, bool|int $pretty = false, bool $escapeUnicode = false)

Converts value to JSON format. Use $pretty for easier reading and clarity and $escapeUnicode for ASCII output.

Parameters

mixed $value
bool|int $pretty
bool $escapeUnicode

Return Value

string

Exceptions

JsonException

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

Parses JSON to PHP value. Parameter $forceArray forces an array instead of an object as the return value.

Parameters

string $json
bool|int $forceArray

Return Value

mixed

Exceptions

JsonException

Traits

Static class.