protected function getJsonResponse($address, $method = self::METHOD_GET, \stdClass $body = null)
{
// Build request url
$url = "http://{$this->client->getHost()}{$address}";
// Open connection
$this->getAdapter()->open();
// Send and get response
$results = $this->getAdapter()->send($url, $method, $body ? json_encode($body) : null);
$status = $this->getAdapter()->getHttpStatusCode();
$contentType = $this->getAdapter()->getContentType();
// Throw connection exception if status code isn't 200 or wrong content type
if ($status != 200 || $contentType != 'application/json') {
throw new ConnectionException('Connection failure');
}
// Parse json results
$jsonResults = json_decode($results);
return $jsonResults;
}