namespace Symfony\Component\Serializer\Encoder;
-use Symfony\Component\Serializer\Exception\UnexpectedValueException;
+use Symfony\Component\Serializer\Exception\NotEncodableValueException;
/**
* Decodes JSON data.
*/
class JsonDecode implements DecoderInterface
{
- /**
- * Specifies if the returned result should be an associative array or a nested stdClass object hierarchy.
- *
- * @var bool
- */
- private $associative;
+ protected $serializer;
- /**
- * Specifies the recursion depth.
- *
- * @var int
- */
+ private $associative;
private $recursionDepth;
- private $lastError = JSON_ERROR_NONE;
-
- protected $serializer;
-
/**
* Constructs a new JsonDecode instance.
*
*
* @return mixed
*
- * @throws UnexpectedValueException
+ * @throws NotEncodableValueException
*
* @see http://php.net/json_decode json_decode
*/
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
- if (JSON_ERROR_NONE !== $this->lastError = json_last_error()) {
- throw new UnexpectedValueException(json_last_error_msg());
+ if (JSON_ERROR_NONE !== json_last_error()) {
+ throw new NotEncodableValueException(json_last_error_msg());
}
return $decodedData;
/**
* Merges the default options of the Json Decoder with the passed context.
*
- * @param array $context
- *
* @return array
*/
private function resolveContext(array $context)