/** * @param \CurlResponse $response * @return \stdClass * @throws JsonException */ protected function getResponseBody(\CurlResponse $response) { try { return Json::decode($response->body); } catch (HampelJsonException $e) { throw new JsonException($e->getMessage(), $e->getCode()); } }
/** * Render array data as json with json_decode * * @param array $data */ protected function renderJson(array $data, $status = 200) { try { $json = Json::encode($data); $this->render($json, $status); } catch (JsonException $ex) { $this->render('Data not valid', 400); } }