Fix JsonDecode to work on PHP 5.3, update the CHANGELOG.md

This commit is contained in:
Benjamin Eberlei 2013-01-19 00:06:48 +01:00
parent b6bdb450e3
commit fcabadfc23
2 changed files with 16 additions and 1 deletions

View File

@ -1,6 +1,16 @@
CHANGELOG
=========
2.2.0
-----
* All Serializer, Normalizer and Encoder interfaces have been
modified to include an optional ``$context`` array parameter.
* The XML Root name can now be configured with the ``xml_root_name``
parameter in the context option to the ``XmlEncoder``.
* Options to ``json_encode`` and ``json_decode`` can be passed through
the context options of ``JsonEncode`` and ``JsonDecode`` encoder/decoders.
2.1.0
-----

View File

@ -57,7 +57,12 @@ class JsonDecode implements DecoderInterface
$recursionDepth = $context['json_decode_recursion_depth'];
$options = $context['json_decode_options'];
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
$decodedData = json_decode($data, $associative, $recursionDepth, $options);
} else {
$decodedData = json_decode($data, $associative, $recursionDepth);
}
$this->lastError = json_last_error();
return $decodedData;