JsonDecode
in package
implements
DecoderInterface
Decodes JSON data.
Tags
Interfaces, Classes, Traits and Enums
Table of Contents
- ASSOCIATIVE = 'json_decode_associative'
- True to return the result as an associative array, false for a nested stdClass hierarchy.
- OPTIONS = 'json_decode_options'
- RECURSION_DEPTH = 'json_decode_recursion_depth'
- Specifies the recursion depth.
- $serializer : mixed
- $defaultContext : mixed
- __construct() : mixed
- Constructs a new JsonDecode instance.
- decode() : mixed
- Decodes data.
- supportsDecoding() : bool
- Checks whether the deserializer can decode from given format.
Constants
ASSOCIATIVE
True to return the result as an associative array, false for a nested stdClass hierarchy.
public
mixed
ASSOCIATIVE
= 'json_decode_associative'
OPTIONS
public
mixed
OPTIONS
= 'json_decode_options'
RECURSION_DEPTH
Specifies the recursion depth.
public
mixed
RECURSION_DEPTH
= 'json_decode_recursion_depth'
Properties
$serializer
protected
mixed
$serializer
$defaultContext
private
mixed
$defaultContext
= [self::ASSOCIATIVE => false, self::OPTIONS => 0, self::RECURSION_DEPTH => 512]
Methods
__construct()
Constructs a new JsonDecode instance.
public
__construct([array<string|int, mixed> $defaultContext = [] ][, int $depth = 512 ]) : mixed
Parameters
- $defaultContext : array<string|int, mixed> = []
- $depth : int = 512
Return values
mixed —decode()
Decodes data.
public
decode(string $data, string $format[, array<string|int, mixed> $context = [] ]) : mixed
Parameters
- $data : string
-
The encoded JSON string to decode
- $format : string
-
Must be set to JsonEncoder::FORMAT
- $context : array<string|int, mixed> = []
-
An optional set of options for the JSON decoder; see below
The $context array is a simple key=>value array, with the following supported keys:
json_decode_associative: boolean If true, returns the object as an associative array. If false, returns the object as nested stdClass If not specified, this method will use the default set in JsonDecode::__construct
json_decode_recursion_depth: integer Specifies the maximum recursion depth If not specified, this method will use the default set in JsonDecode::__construct
json_decode_options: integer Specifies additional options as per documentation for json_decode
Tags
Return values
mixed —supportsDecoding()
Checks whether the deserializer can decode from given format.
public
supportsDecoding(mixed $format) : bool
Parameters
- $format : mixed
-
Format name