当前位置: 首页>>代码示例>>PHP>>正文


PHP Helpers::jsonEncode方法代码示例

本文整理汇总了PHP中Helpers::jsonEncode方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::jsonEncode方法的具体用法?PHP Helpers::jsonEncode怎么用?PHP Helpers::jsonEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Helpers的用法示例。


在下文中一共展示了Helpers::jsonEncode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createRequest

 /**
  * @param  string  Http\Request::GET|POST|...
  * @param  string  path like '/users/:user/repos' where ':user' is substitution
  * @param  array[name => value]  replaces substitutions in $urlPath, the rest is appended as query string to URL
  * @param  array[name => value]  name is case-insensitive
  * @param  mixed|NULL  arrays and objects are encoded to JSON and Content-Type is set
  * @return Http\Request
  *
  * @throws MissingParameterException  when substitution is used in URL but parameter is missing
  * @throws JsonException  when encoding to JSON fails
  */
 public function createRequest($method, $urlPath, array $parameters = [], array $headers = [], $content = NULL)
 {
     $parameters += $this->defaultParameters;
     $this->substituteUrlParameters($urlPath, $parameters);
     $url = rtrim($this->url, '/') . '/' . trim($urlPath, '/');
     if (count($parameters)) {
         $url .= '?' . http_build_query($parameters);
     }
     if ($content !== NULL && (is_array($content) || is_object($content))) {
         $headers['Content-Type'] = 'application/json; charset=utf-8';
         $content = Helpers::jsonEncode($content);
     }
     return new Http\Request($method, $url, $headers, $content);
 }
开发者ID:ElvenSpellmaker,项目名称:github-api,代码行数:25,代码来源:Api.php

示例2: createRequest

 /**
  * @param  string  Http\Request::GET|POST|...
  * @param  string  path like '/users/:user/repos' where ':user' is substitution
  * @param  array[name => value]  replaces substitutions in $urlPath, the rest is appended as query string to URL
  * @param  array[name => value]  name is case-insensitive
  * @param  mixed|NULL  arrays and objects are encoded to JSON and Content-Type is set
  * @return Http\Request
  *
  * @throws MissingParameterException  when substitution is used in URL but parameter is missing
  * @throws JsonException  when encoding to JSON fails
  */
 public function createRequest($method, $urlPath, array $parameters = [], array $headers = [], $content = NULL)
 {
     if (stripos($urlPath, $this->url) === 0) {
         $urlPath = substr($urlPath, strlen($this->url));
     }
     if (strpos($urlPath, '{') === FALSE) {
         $urlPath = $this->expandColonParameters($urlPath, $parameters, $this->defaultParameters);
     } else {
         $urlPath = $this->expandUriTemplate($urlPath, $parameters, $this->defaultParameters);
     }
     $url = rtrim($this->url, '/') . '/' . ltrim($urlPath, '/');
     if ($content !== NULL && (is_array($content) || is_object($content))) {
         $headers['Content-Type'] = 'application/json; charset=utf-8';
         $content = Helpers::jsonEncode($content);
     }
     return new Http\Request($method, $url, $headers, $content);
 }
开发者ID:runt18,项目名称:github-api-1,代码行数:28,代码来源:Api.php

示例3: processRequestOutput_json

 protected function processRequestOutput_json(array $_)
 {
     return Helpers::jsonEncode($_["result"], 500);
 }
开发者ID:keradus,项目名称:ker,代码行数:4,代码来源:Server.php

示例4: createRequest

 /**
  * @param  string  Http\Request::GET|POST|...
  * @param  string  path like '/users/:user/repos' where ':user' is substitution
  * @param  array[name => value]  replaces substitutions in $urlPath, the rest is appended as query string to URL
  * @param  array[name => value]  name is case-insensitive
  * @param  mixed|NULL  arrays and objects are encoded to JSON and Content-Type is set
  * @return Http\Request
  *
  * @throws MissingParameterException  when substitution is used in URL but parameter is missing
  * @throws JsonException  when encoding to JSON fails
  */
 public function createRequest($method, $urlPath, array $parameters = [], array $headers = [], $content = NULL)
 {
     if (stripos($urlPath, $this->url) === 0) {
         # Allows non-HTTPS URLs
         $baseUrl = $this->url;
         $urlPath = substr($urlPath, strlen($this->url));
     } elseif (preg_match('#^(https://[^/]+)(/.*)?$#', $urlPath, $m)) {
         $baseUrl = $m[1];
         $urlPath = isset($m[2]) ? $m[2] : '';
     } else {
         $baseUrl = $this->url;
     }
     if (strpos($urlPath, '{') === FALSE) {
         $urlPath = $this->expandColonParameters($urlPath, $parameters, $this->defaultParameters);
     } else {
         $urlPath = $this->expandUriTemplate($urlPath, $parameters, $this->defaultParameters);
     }
     $url = rtrim($baseUrl, '/') . '/' . ltrim($urlPath, '/');
     if ($content !== NULL && (is_array($content) || is_object($content))) {
         $headers['Content-Type'] = 'application/json; charset=utf-8';
         $content = Helpers::jsonEncode($content);
     }
     return new Http\Request($method, $url, $headers, $content);
 }
开发者ID:milo,项目名称:github-api,代码行数:35,代码来源:Api.php

示例5: sendRequest_encodeData_json

 public function sendRequest_encodeData_json(array $_)
 {
     return Helpers::jsonEncode($_);
 }
开发者ID:keradus,项目名称:ker,代码行数:4,代码来源:Client.php


注:本文中的Helpers::jsonEncode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。