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::DETAILED_ERROR_MESSAGES = 'json_decode_detailed_errors'
 

True to enable seld/jsonlint as a source for more specific error messages when json_decode fails.

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 json_decode_detailed_errors: bool If true, enables seld/jsonlint as a source for more specific error messages when json_decode fails. If false or not specified, this method will use default error messages from PHP's json_decode
  • throws \NotEncodableValueException
  • see https://php.net/json_decode
public supportsDecoding(string $format) : bool
Properties
protected $serializer = NULL
 
  • deprecated since Symfony 6.4, to be removed in 7.0
Properties
private array $defaultContext = ['json_decode_associative' => false, 'json_decode_detailed_errors' => false, 'json_decode_options' => 0, 'json_decode_recursion_depth' => 512]
© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration