JsonSerializer
in package
implements
Serializer
FinalYes
Table of Contents
Interfaces
Constants
- THROW_ON_ERROR = 4194304
Properties
- $associative : bool
- $decodeOptions : int
- $depth : int
- $encodeOptions : int
Methods
- serialize() : string
- unserialize() : mixed
- withAssociativeArrays() : self
- Creates a JSON serializer that decodes objects to associative arrays.
- withObjects() : self
- Creates a JSON serializer that decodes objects to instances of stdClass.
- __construct() : mixed
Constants
THROW_ON_ERROR
private
mixed
THROW_ON_ERROR
= 4194304
Properties
$associative
private
bool
$associative
$decodeOptions
private
int
$decodeOptions
$depth
private
int
$depth
$encodeOptions
private
int
$encodeOptions
Methods
serialize()
public
serialize(mixed $data) : string
Parameters
- $data : mixed
Return values
stringunserialize()
public
unserialize(string $data) : mixed
Parameters
- $data : string
Return values
mixed —The unserialized data.
withAssociativeArrays()
Creates a JSON serializer that decodes objects to associative arrays.
public
static withAssociativeArrays([int $encodeOptions = 0 ][, int $decodeOptions = 0 ][, int $depth = 512 ]) : self
Parameters
- $encodeOptions : int = 0
-
@see \json_encode() options parameter.
- $decodeOptions : int = 0
-
@see \json_decode() options parameter.
- $depth : int = 512
-
Maximum recursion depth.
Return values
selfwithObjects()
Creates a JSON serializer that decodes objects to instances of stdClass.
public
static withObjects([int $encodeOptions = 0 ][, int $decodeOptions = 0 ][, int $depth = 512 ]) : self
Parameters
- $encodeOptions : int = 0
-
@see \json_encode() options parameter.
- $decodeOptions : int = 0
-
@see \json_decode() options parameter.
- $depth : int = 512
-
Maximum recursion depth.
Return values
self__construct()
private
__construct(bool $associative[, int $encodeOptions = 0 ][, int $decodeOptions = 0 ][, int $depth = 512 ]) : mixed
Parameters
- $associative : bool
- $encodeOptions : int = 0
- $decodeOptions : int = 0
- $depth : int = 512