class Json

JSON encoder and decoder.

Traits

Static class.

Constants

FORCE_ARRAY

PRETTY

ESCAPE_UNICODE

Methods

static string
encode($value, int $flags = 0)

Converts value to JSON format. The flag can be Json::PRETTY, which formats JSON for easier reading and clarity, and Json::ESCAPE_UNICODE for ASCII output.

static mixed
decode(string $json, int $flags = 0)

Parses JSON to PHP value. The flag can be Json::FORCE_ARRAY, which forces an array instead of an object as the return value.

Details

at line 35
static string encode($value, int $flags = 0)

Converts value to JSON format. The flag can be Json::PRETTY, which formats JSON for easier reading and clarity, and Json::ESCAPE_UNICODE for ASCII output.

Parameters

$value
int $flags

Return Value

string

Exceptions

JsonException

at line 55
static mixed decode(string $json, int $flags = 0)

Parses JSON to PHP value. The flag can be Json::FORCE_ARRAY, which forces an array instead of an object as the return value.

Parameters

string $json
int $flags

Return Value

mixed

Exceptions

JsonException