public function Response::json

Parse the JSON response body and return an array

Return value

array

Throws

RuntimeException if the response body is not in JSON format

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Response.php, line 917

Class

Response
Guzzle HTTP response object

Namespace

Guzzle\Http\Message

Code

public function json() {
  $data = json_decode((string) $this->body, true);
  if (JSON_ERROR_NONE !== json_last_error()) {
    throw new RuntimeException('Unable to parse response body into JSON: ' . json_last_error());
  }
  return $data ?: array();
}