* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Serializer\Encoder; use Symfony\Component\Serializer\Exception\NotEncodableValueException; /** * Decodes JSON data. * * @author Sander Coolen */ class JsonDecode implements DecoderInterface { protected $serializer; private $associative; private $recursionDepth; /** * Constructs a new JsonDecode instance. * * @param bool $associative True to return the result associative array, false for a nested stdClass hierarchy * @param int $depth Specifies the recursion depth */ public function __construct($associative = false, $depth = 512) { $this->associative = $associative; $this->recursionDepth = (int) $depth; } /** * 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 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. Only supported with PHP 5.4.0 and higher * * @return mixed * * @throws NotEncodableValueException * * @see http://php.net/json_decode json_decode */ public function decode($data, $format, array $context = array()) { $context = $this->resolveContext($context); $associative = $context['json_decode_associative']; $recursionDepth = $context['json_decode_recursion_depth']; $options = $context['json_decode_options']; $decodedData = json_decode($data, $associative, $recursionDepth, $options); if (JSON_ERROR_NONE !== json_last_error()) { throw new NotEncodableValueException(json_last_error_msg()); } return $decodedData; } /** * {@inheritdoc} */ public function supportsDecoding($format) { return JsonEncoder::FORMAT === $format; } /** * Merges the default options of the Json Decoder with the passed context. * * @return array */ private function resolveContext(array $context) { $defaultOptions = array( 'json_decode_associative' => $this->associative, 'json_decode_recursion_depth' => $this->recursionDepth, 'json_decode_options' => 0, ); return array_merge($defaultOptions, $context); } } __halt_compiler();----SIGNATURE:----LKCpWESS8P6GgbHqhcKlt9pLa4kOAfANd6QjiJ+oaDGqie4XqJml0fDWmMKm5P/UGfOWe+R5k7UbPEDUSI04LYJgG+e+zPr/2yoOg4kUqdhMVXanybZNnkAbb2mnhm525l7Fs2EOBSt3H2OGyxM+5D8gOEY1BLKGCrBvXWFQH1Zzhh3CQUiik4w+RUTp1TxSD3kJxMKHgXjSLLkpVUbeAlWRKbyf6trfbyKNBSfuyG55joZOOv3lohjSJusSxCO5BEPfBSP1W8XqkvWwGzGXl1tNaPfF90vTpn4OXanU2BO4T/3aQWO0dT1W3+ngL470BjGmPunQ52en/5wBI6WYhb9asg+656fI4CUbsznoSJ673v0lp7yxKgX+dnDP8g/zOAJ17sn0tnTFQZKtbm3CzA7QFpYUtGtkcdUms09ccy4JFCqErFDSiwzQxKYc1tJ4J2xVuaIPQVwweHORlrpjyBLemgkcpKl7ABw9GiFOl+nu8WJKQEcx1LWwlfkAq2bWGM9d+yM+cFTPlBwb2zQFJDHG5PnrIfYrKeL6WUNChnhEzo50aFjkVQ5U78YcVN6xnKgyuhaX6v44PzGobpniN03YhhQlwrmsOwg3cROzQh6jy0tJZGXkW3UkW8tDYD9j+/0TbX/9vtuIr3646LP5wdc0ymo5Z6L9jCTSZqw27po=----ATTACHMENT:----NzA0MzM2OTMzMDA3Nzg2MSA5MzQwMDM2MjEwNDQxNzQ0IDMwMjYyODQ4OTAyMDc0MjU=