Copied!

Decodes JSON data.

CloneableInstantiable
Constants
public Symfony\Component\Serializer\Encoder\JsonDecode::ASSOCIATIVE = 'json_decode_associative'
 

True to return the result as an associative array, false for a nested stdClass hierarchy.

public Symfony\Component\Serializer\Encoder\JsonDecode::OPTIONS = 'json_decode_options'
public Symfony\Component\Serializer\Encoder\JsonDecode::RECURSION_DEPTH = 'json_decode_recursion_depth'
 

Specifies the recursion depth.

Methods
public __construct(array $defaultContext = [])
public decode(string $data, string $format, array $context = []) : ?mixed
 

Decodes data.

  • param string $data The encoded JSON string to decode
  • param string $format Must be set to JsonEncoder::FORMAT
  • param array $context 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
  • throws \NotEncodableValueException
  • see https://php.net/json_decode
public supportsDecoding(string $format) : bool
Properties
protected $serializer = NULL
Properties
private array $defaultContext = ['json_decode_associative' => false, 'json_decode_options' => 0, 'json_decode_recursion_depth' => 512]
© 2023 Bruce Wells
Search Namespaces \ Classes
Configuration