當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Helpers::jsonDecode方法代碼示例

本文整理匯總了PHP中Helpers::jsonDecode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Helpers::jsonDecode方法的具體用法?PHP Helpers::jsonDecode怎麽用?PHP Helpers::jsonDecode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Helpers的用法示例。


在下文中一共展示了Helpers::jsonDecode方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: processRequestParams_json

 protected function processRequestParams_json($_data)
 {
     return Helpers::jsonDecode($_data, 500);
 }
開發者ID:keradus,項目名稱:ker,代碼行數:4,代碼來源:Server.php

示例2: decode

 /**
  * @param  Http\Response
  * @param  array|NULL  these codes are treated as success; code < 300 if NULL
  * @return mixed
  *
  * @throws ApiException
  */
 public function decode(Http\Response $response, array $okCodes = NULL)
 {
     $content = $response->getContent();
     if (preg_match('~application/json~i', $response->getHeader('Content-Type', ''))) {
         try {
             $content = Helpers::jsonDecode($response->getContent());
         } catch (JsonException $e) {
             throw new InvalidResponseException('JSON decoding failed.', 0, $e, $response);
         }
         if (!is_array($content) && !is_object($content)) {
             throw new InvalidResponseException('Decoded JSON is not an array or object.', 0, NULL, $response);
         }
     }
     $code = $response->getCode();
     if ($okCodes === NULL && $code >= 300 && $code != 304 || is_array($okCodes) && !in_array($code, $okCodes)) {
         /** @var $content \stdClass */
         switch ($code) {
             case Http\Response::S400_BAD_REQUEST:
                 throw new BadRequestException($content->message, $code, NULL, $response);
             case Http\Response::S401_UNAUTHORIZED:
                 throw new UnauthorizedException($content->message, $code, NULL, $response);
             case Http\Response::S403_FORBIDDEN:
                 if ($response->getHeader('X-RateLimit-Remaining') === '0') {
                     throw new RateLimitExceedException($content->message, $code, NULL, $response);
                 }
                 throw new ForbiddenException($content->message, $code, NULL, $response);
             case Http\Response::S404_NOT_FOUND:
                 throw new NotFoundException('Resource not found or not authorized to access.', $code, NULL, $response);
             case Http\Response::S422_UNPROCESSABLE_ENTITY:
                 $message = $content->message . implode(', ', array_map(function ($error) {
                     return '[' . implode(':', (array) $error) . ']';
                 }, $content->errors));
                 throw new UnprocessableEntityException($message, $code, NULL, $response);
         }
         $message = $okCodes === NULL ? '< 300' : implode(' or ', $okCodes);
         throw new UnexpectedResponseException("Expected response with code {$message}.", $code, NULL, $response);
     }
     return $content;
 }
開發者ID:ElvenSpellmaker,項目名稱:github-api,代碼行數:46,代碼來源:Api.php

示例3: sendRequest_decodeData_json

 public function sendRequest_decodeData_json($_data)
 {
     return Helpers::jsonDecode($_data);
 }
開發者ID:keradus,項目名稱:ker,代碼行數:4,代碼來源:Client.php


注:本文中的Helpers::jsonDecode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。