コード例 #1
0
ファイル: BaseApi.php プロジェクト: ondrs/vehico-api
 /**
  * @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());
     }
 }
コード例 #2
0
ファイル: AbstractController.php プロジェクト: nogo/feedbox
 /**
  * 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);
     }
 }