public function checkJSONResponse($json) { if (!JSONUtil::isValid($json)) { throw new WrongResponseException('Invalid JSON'); } $json = json_decode($json); if (isset($json->exception)) { throw new WrongResponseException($json->exception->message); } return $json; }
private function convertTo($type) { switch (strtolower($type)) { case 'json': if (JSONUtil::isValid($this->body)) { return $this->body; } return @json_encode($this->body); default: return $this->body; } }