当前位置: 首页>>代码示例>>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;未经允许,请勿转载。