feat(json): json pecl extension may be available all the time

This commit is contained in:
Ahmad Nassri
2016-02-24 22:07:25 -05:00
parent f7f13bd940
commit 0f3a22d63e
3 changed files with 12 additions and 7 deletions

View File

@@ -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;
}
}
}