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


PHP Services_JSON::isError方法代码示例

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


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

示例1: decodeJson

 /**
  * JSON 形式の文字列を値に変換します。
  *
  * @param string $json
  * @param bool $returnAssoc
  * @throws RuntimeException
  * @return mixed
  */
 public static function decodeJson($json, $returnAssoc = false)
 {
     if (function_exists('json_decode') && function_exists('json_last_error')) {
         $native = json_decode($json, $returnAssoc);
         $error = json_last_error();
         if ($error !== JSON_ERROR_NONE) {
             $message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'error code: ' . $error;
             throw new RuntimeException($message, $error);
         }
         return $native;
     }
     // オートローダーを働かせて定数を定義させる。
     class_exists('Services_JSON');
     $options = $returnAssoc ? SERVICES_JSON_LOOSE_TYPE : 0;
     $decoder = new Services_JSON($options);
     $native = $decoder->decode($json);
     if (Services_JSON::isError($json)) {
         throw new RuntimeException($native->toString(), $native->getCode());
     }
     return $native;
 }
开发者ID:zenith6,项目名称:eccube-zeclib,代码行数:29,代码来源:Compat.php

示例2: name_value

 /**
  * array-walking function for use in generating JSON-formatted name-value pairs
  *
  * @param    string  $name   name of key to use
  * @param    mixed   $value  reference to an array element to be encoded
  *
  * @return   string  JSON-formatted name-value pair, like '"name":value'
  * @access   private
  */
 function name_value($name, $value)
 {
     $encoded_value = $this->encode($value);
     if (Services_JSON::isError($encoded_value)) {
         return $encoded_value;
     }
     return $this->encode(strval($name)) . ':' . $encoded_value;
 }
开发者ID:sauruscms,项目名称:Saurus-CMS-Community-Edition,代码行数:17,代码来源:Services_JSON.class.php

示例3: name_value

 function name_value($name, $value)
 {
     $encoded_value = $this->_encode($value);
     if (Services_JSON::isError($encoded_value)) {
         return $encoded_value;
     }
     $lv = strval($name);
     // do not escape keyvalues if they are just text, and not keywords...
     if (preg_match('/^[a-z_]+$/i', $lv)) {
         if (!in_array($lv, $GLOBALS['Pman_Builder_Generator_JSON']['keywords'])) {
             return $lv . ' : ' . $encoded_value;
         }
     }
     return $this->_encode(strval($name)) . ' : ' . $encoded_value;
 }
开发者ID:roojs,项目名称:Pman.Builder,代码行数:15,代码来源:JSON.php

示例4: test_to_JSON

 function test_to_JSON()
 {
     $this->assertTrue(Services_JSON::isError($this->json->encode($this->res)), "resource case: {$this->res_d}");
     $this->assertTrue(Services_JSON::isError($this->json->encode($this->arr)), "array case: {$this->arr_d}");
     $this->assertTrue(Services_JSON::isError($this->json->encode($this->obj)), "object case: {$this->obj_d}");
 }
开发者ID:BackupTheBerlios,项目名称:thinkedit-svn,代码行数:6,代码来源:Test-JSON.php

示例5: name_value

 /**
  * array-walking function for use in generating JSON-formatted name-value pairs
  *
  * @param    string  $name   name of key to use
  * @param    mixed   $value  reference to an array element to be encoded
  *
  * @return   string  JSON-formatted name-value pair, like '"name":value'
  * @access   private
  */
 static function name_value($name, $value)
 {
     $encoded_value = self::encode($value);
     if (Services_JSON::isError($encoded_value)) {
         return $encoded_value;
     }
     return self::encode(strval($name)) . ':' . $encoded_value;
 }
开发者ID:rudiedirkx,项目名称:Games,代码行数:17,代码来源:inc.cls.json_php5.php

示例6: stdclass

 /**
  * Create a JSON-RPC client
  *
  * @param string $method A valid Mail API JSON-RPC method
  * @param string $args Parameters for your method
  * @return string | false If successful, a string is returned containing the JSON
  * data decoded into a PHP array. If a curl or JSON encode/decode
  * error occurs, the error is stored in $this->web_services_error. Note that
  * access to the HTTP status code (for further error checking) is not provided
  * in this method.
  */
 function __call($method, $args)
 {
     $body = new stdclass();
     $body->method = $method;
     $body->params = $args;
     // Use the JSON PHP extension if it's available
     if (function_exists('json_encode')) {
         // Anything json_encode can't encode is encoded as nulls
         $data = json_encode($body);
     } else {
         $json = new Services_JSON();
         $data = $json->encode($body);
         if ($json->isError($data)) {
             $this->web_services_error = "Error encoding JSON";
             return false;
         }
     }
     $ch = curl_init(self::jsonrpc_endpoint . "?appid={$this->appid}&WSSID={$this->WSSID}");
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Cookie: {$this->cookie}"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $jsondata = curl_exec($ch);
     if (curl_errno($ch)) {
         $this->web_services_error = "Curl error number: " . curl_errno($ch);
         return false;
     }
     curl_close($ch);
     // Use the JSON PHP extension if it's available
     if (function_exists('json_encode')) {
         $data = json_decode($jsondata);
         if ($data == null) {
             $this->web_services_error = "Error decoding JSON";
             return false;
         }
     } else {
         $data = $json->decode($jsondata);
         if ($json->isError($data)) {
             $this->web_services_error = "Error decoding JSON";
             return false;
         }
     }
     return $data;
 }
开发者ID:ajbm6,项目名称:raphpframework,代码行数:55,代码来源:ybrowserauth.class.php


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