diff --git a/.gitignore b/.gitignore index 2af185b..3a25e7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -.idea .DS_Store +.idea build -vendor composer.lock composer.phar +coverage +vendor diff --git a/composer.json b/composer.json index c5c0696..dd8cd99 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,10 @@ "author": "Mashape (https://www.mashape.com)", "require": { "php": ">=5.4.0", - "ext-curl": "*", - "ext-json": "*" + "ext-curl": "*" + }, + "suggest": { + "ext-json": "Allows using JSON Bodies for sending and parsing requests" }, "require-dev": { "phpunit/phpunit": "~4.4", diff --git a/src/Unirest/Response.php b/src/Unirest/Response.php index 9493de1..99eaed0 100644 --- a/src/Unirest/Response.php +++ b/src/Unirest/Response.php @@ -25,10 +25,12 @@ class Response // make sure raw_body is the first argument array_unshift($json_args, $raw_body); - $json = call_user_func_array('json_decode', $json_args); + if (function_exists('json_decode')) { + $json = call_user_func_array('json_decode', $json_args); - if (json_last_error() === JSON_ERROR_NONE) { - $this->body = $json; + if (json_last_error() === JSON_ERROR_NONE) { + $this->body = $json; + } } }