Json
in package
uses
StaticClass
FinalYes
JSON encoder and decoder.
Table of Contents
Constants
- ESCAPE_UNICODE = 1 << 19
- FORCE_ARRAY = JSON_OBJECT_AS_ARRAY
- PRETTY = JSON_PRETTY_PRINT
Methods
- __callStatic() : mixed
- Call to undefined static method.
- decode() : mixed
- Parses JSON to PHP value. The $forceArrays enforces the decoding of objects as arrays.
- encode() : string
- 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.
- __construct() : mixed
- Class is static and cannot be instantiated.
Constants
ESCAPE_UNICODE
use Json::encode(..., asciiSafe: true)
public
mixed
ESCAPE_UNICODE
= 1 << 19
FORCE_ARRAY
use Json::decode(..., forceArrays: true)
public
mixed
FORCE_ARRAY
= JSON_OBJECT_AS_ARRAY
PRETTY
use Json::encode(..., pretty: true)
public
mixed
PRETTY
= JSON_PRETTY_PRINT
Methods
__callStatic()
Call to undefined static method.
public
static __callStatic(string $name, array<string|int, mixed> $args) : mixed
Parameters
- $name : string
- $args : array<string|int, mixed>
Tags
decode()
Parses JSON to PHP value. The $forceArrays enforces the decoding of objects as arrays.
public
static decode(string $json[, bool|int $forceArrays = false ]) : mixed
Parameters
- $json : string
- $forceArrays : bool|int = false
Tags
encode()
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.
public
static encode(mixed $value[, bool|int $pretty = false ][, bool $asciiSafe = false ][, bool $htmlSafe = false ][, bool $forceObjects = false ]) : string
Parameters
- $value : mixed
- $pretty : bool|int = false
- $asciiSafe : bool = false
- $htmlSafe : bool = false
- $forceObjects : bool = false
Tags
Return values
string__construct()
Class is static and cannot be instantiated.
private
__construct() : mixed