Beispiel #1
0
 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;
 }
Beispiel #2
0
 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;
     }
 }