Skip to content

Commit

Permalink
Adjust to new json_decode behaviour in php > 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
maximkott committed May 24, 2017
1 parent ae3fadc commit 7de1863
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Weew/JsonEncoder/JsonEncoder.php
Expand Up @@ -49,6 +49,10 @@ public function encode($data, $options = 0) {
* @throws JsonDecodeException
*/
function decode($json, $assoc = true, $depth = 512, $options = 0) {
if (array_contains(['', null], $json)) {
return null;
}

$data = @json_decode($json, $assoc, $depth, $options);

if ($data === null && json_last_error() !== JSON_ERROR_NONE) {
Expand Down

0 comments on commit 7de1863

Please sign in to comment.