• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_json函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中is_json函数的典型用法代码示例。如果您正苦于以下问题:PHP is_json函数的具体用法?PHP is_json怎么用?PHP is_json使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: writeObjectParts

 public static function writeObjectParts($obj)
 {
     ////var_dump("writing obj: " . $obj["varname"]);
     ////var_dump($obj);
     $adjObj = array();
     foreach ($obj as $key => $value) {
         $strkey = strval($key);
         if (substr($strkey, 0, 1) == "/") {
             $strkey = substr($strkey, 1);
         }
         $adjObj[$strkey] = $value;
     }
     $obj = $adjObj;
     foreach ($obj as $key => $value) {
         $strkey = strval($key);
         if ($value == null) {
             ////var_dump("reading null: " . $obj["varname"] . "." . $strkey);
             $value = PiPress::getVar($obj["varname"] . "." . $strkey);
         }
         if (is_string($value) && is_json($value)) {
             ////var_dump("json string");
             $value = json_decode($value, true);
         }
         ////var_dump("dump1: ");
         ////var_dump($value);
         if (is_array($value)) {
             $value["varname"] = $obj["varname"] . "." . $strkey;
             //var_dump($value["varname"]);
             PiPress::writeObjectParts($value);
             $obj[$key] = null;
         }
     }
     //PiPress::createDocumentation($obj);
     file_put_contents("./" . $obj["varname"] . ".json", json_encode($obj));
 }
开发者ID:saurabhsrb,项目名称:pipress,代码行数:35,代码来源:piBeta.php


示例2: __construct

 function __construct()
 {
     parent::__construct();
     if ($this->config->item('use_db_config')) {
         // Get CI instance so we can set a global var.
         $CI =& get_instance();
         // First check memcache, if found use dbconfig from memcache
         if ($cached = $this->memcache->get('dbconfig')) {
             // Override data origin.
             $cached->_data_origin = 'memcached';
             $CI->dbconfig = $cached;
             return true;
         }
         // Get config from db
         $result = $this->db->select('key, value')->get('config')->result();
         // Create new array and set data origin
         $dbconf = array('_data_origin' => 'database');
         // Loop through db-result.
         foreach ($result as $conf) {
             $dbconf[addslashes($conf->key)] = is_json($conf->value) ? json_decode($conf->value) : $conf->value;
         }
         // Cache in memcache forever
         $this->memcache->set('dbconfig', (object) $dbconf, 0);
     } else {
         // Default to an empty array
         $dbconf = array();
     }
     // Set dbconfig from database result.
     $CI->dbconfig = (object) $dbconf;
 }
开发者ID:johusman,项目名称:internal,代码行数:30,代码来源:dbconfig.php


示例3: getContentAttribute

 /**
  * Menu json to array.
  *
  * @param $content
  * @return mixed
  */
 public function getContentAttribute($content)
 {
     if (is_json($content)) {
         return json_decode($content);
     }
     return $content;
 }
开发者ID:chictem,项目名称:chictem,代码行数:13,代码来源:Menu.php


示例4: Curl

function Curl($url, $method = 'GET', $postData = array())
{
    $data = '';
    if (!empty($url)) {
        try {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_HEADER, false);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, 30);
            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
            if (is_json($postData)) {
                curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
            }
            if (strtoupper($method) == 'POST') {
                $curlPost = is_array($postData) ? http_build_query($postData) : $postData;
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
            }
            $data = curl_exec($ch);
            curl_close($ch);
        } catch (Exception $e) {
            $data = null;
        }
    }
    return $data;
}
开发者ID:sanshilei,项目名称:password,代码行数:27,代码来源:pass.php


示例5: valueFromUrl

 public static function valueFromUrl($_url)
 {
     $request_http = new com_http($_url);
     $dataUrl = $request_http->exec();
     if (!is_json($dataUrl)) {
         return;
     }
     return json_decode($dataUrl, true);
 }
开发者ID:jeedom,项目名称:plugin-ecowatt,代码行数:9,代码来源:ecowatt.class.php


示例6: categorization

 function categorization($id = null)
 {
     header('Content-Type: application/json');
     $cat = $this->categorization_model->get_categorization($id);
     $cat_settings = array_get_value((array) $cat, 'cat_settings');
     $cat_settings = unserialize($cat_settings);
     $cat_settings = $cat_settings && is_json($cat_settings) ? $cat_settings : json_encode(array('url' => base_url('data/category-builder-template.js')), JSON_UNESCAPED_SLASHES);
     echo $cat_settings;
 }
开发者ID:benznext,项目名称:CIDashboard,代码行数:9,代码来源:api.php


示例7: decode

 /**
  * Decode a request result.
  *
  * @param $body
  * @return mixed
  */
 private function decode($body)
 {
     if (is_json($body)) {
         return json_decode($body, true);
     }
     if (is_xml($body)) {
         return xml_to_json($body);
     }
     return $body;
 }
开发者ID:wsorprendente,项目名称:zipcode,代码行数:16,代码来源:Http.php


示例8: doImport

 public function doImport()
 {
     $jsonData = file_get_contents($this->importFile);
     if (is_json($jsonData) === false) {
         throw new Exception('El fichero de importación no parece que este en formato json');
     }
     $arrayData = Zend_Json::decode($jsonData, Zend_Json::TYPE_ARRAY);
     foreach ($arrayData as $roleData) {
         $this->createRole($roleData);
     }
 }
开发者ID:jv10,项目名称:pimpon,代码行数:11,代码来源:Import.php


示例9: parse

 public function parse()
 {
     $data = $this->data;
     if (is_array($data)) {
         return $this->arrayParser($data);
     }
     if (is_json($data)) {
         return $this->jsonParser($data);
     }
     return $this->arrayParser($data);
 }
开发者ID:eskrano,项目名称:formbuilder,代码行数:11,代码来源:SelectParser.php


示例10: get_api_data

function get_api_data($url, $param = array())
{
    $url = API_URL . $url;
    $sign = encrypt($param);
    $param['sign'] = $sign;
    $api_str = send_request($url, $param);
    if (is_json($api_str)) {
        return json_decode($api_str, TRUE);
    } else {
        return return_format(array($api_str), "json_str 解析错误,这是api内部报错!请联系[email protected]", API_NORMAL_ERR);
    }
}
开发者ID:codekissyoung,项目名称:filmfest,代码行数:12,代码来源:functions.php


示例11: sendData

 private function sendData($param)
 {
     $url = C('WEB_URL');
     $checkCode = C('CHECK_CODE');
     $param = json_encode($param);
     $post = array('param' => $param, 'sign' => md5($param . $checkCode));
     $data = url_data($url, $post);
     if (is_json($data)) {
         $data = json_decode($data, true);
     }
     return $data;
 }
开发者ID:dalinhuang,项目名称:edu_hipi,代码行数:12,代码来源:SyncLogic.class.php


示例12: testIsJson

 public function testIsJson()
 {
     $this->assertEquals(is_json('[]'), true);
     $this->assertEquals(is_json('[1]'), true);
     $this->assertEquals(is_json('[1.23]'), true);
     $this->assertEquals(is_json('["a"]'), true);
     $this->assertEquals(is_json('["a",1]'), true);
     $this->assertEquals(is_json('[1,"a",["b"]]'), true);
     $this->assertEquals(is_json('x'), false);
     $this->assertEquals(is_json('['), false);
     $this->assertEquals(is_json('[]]'), false);
     $this->assertEquals(is_json('[[]'), false);
     $this->assertEquals(is_json('["a"'), false);
 }
开发者ID:martinlindhe,项目名称:core_dev,代码行数:14,代码来源:htmlTest.php


示例13: debug

 public function debug($method = 'config')
 {
     if (method_exists(__CLASS__, $method)) {
         $result = self::$method(Input::all());
         if (is_array($result)) {
             Helper::ta($result);
         } elseif (is_json($result)) {
             Helper::ta(json_decode($result, TRUE));
         } elseif (is_string($result)) {
             echo $result;
         }
     } else {
         echo 'Error...';
     }
 }
开发者ID:Grapheme,项目名称:lipton,代码行数:15,代码来源:api.controller.php


示例14: requestKeyValue

 public function requestKeyValue($url, $method = 'GET', $fields = [])
 {
     try {
         $response = $this->request($url, $method, $fields);
     } catch (Exception $e) {
         throw $e;
     }
     // Extract body from response.
     $body = $response->getBody();
     // Handle expected json.
     $data = [];
     if (is_json($body, $data)) {
         return $data;
     }
     // Parse body as keyvalue.
     return keyvalue_to_array($body);
 }
开发者ID:furey,项目名称:laravel-facebook-service,代码行数:17,代码来源:FacebookRemote.php


示例15: getVerifyToken

 public function getVerifyToken($id)
 {
     global $table_prefix;
     $id = intval($id);
     if (!$this->isExistID($id)) {
         return FALSE;
     }
     try {
         $sth = $this->dbh->prepare("SELECT * FROM {$table_prefix}users_temp WHERE `id` = :id ");
         $sth->bindParam(':id', $id);
         $sth->execute();
         $result = $sth->fetch(PDO::FETCH_ASSOC);
         $verify_token = $result['verify_token'];
         if (is_json($verify_token)) {
             $verify_token = json_decode($verify_token, true);
         } else {
             $verify_token = array("", "");
         }
         return $verify_token;
     } catch (PDOExecption $e) {
         echo "<br>Error: " . $e->getMessage();
     }
 }
开发者ID:sujinw,项目名称:zjut_passport,代码行数:23,代码来源:class.zusertemp.php


示例16: loadCmdFromConf

 public function loadCmdFromConf($_update = false)
 {
     if (!is_file(dirname(__FILE__) . '/../config/devices/' . $this->getConfFilePath())) {
         return;
     }
     $content = file_get_contents(dirname(__FILE__) . '/../config/devices/' . $this->getConfFilePath());
     if (!is_json($content)) {
         return;
     }
     $device = json_decode($content, true);
     if (!is_array($device) || !isset($device['commands'])) {
         return true;
     }
     $cmd_order = 0;
     $link_cmds = array();
     if (isset($device['name']) && !$_update) {
         $this->setName('[' . $this->getLogicalId() . ']' . $device['name']);
     }
     if (isset($device['configuration'])) {
         foreach ($device['configuration'] as $key => $value) {
             try {
                 $this->setConfiguration($key, $value);
             } catch (Exception $e) {
             }
         }
     }
     nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => __('Création des commandes à partir d\'une configuration', __FILE__)));
     $commands = $device['commands'];
     foreach ($commands as &$command) {
         if (!isset($command['configuration']['instanceId'])) {
             $command['configuration']['instanceId'] = 0;
         }
         if (!isset($command['configuration']['class'])) {
             $command['configuration']['class'] = '';
         }
         try {
             $cmd = new openzwaveCmd();
             $cmd->setOrder($cmd_order);
             $cmd->setEqLogic_id($this->getId());
             utils::a2o($cmd, $command);
             if (isset($command['value'])) {
                 $cmd->setValue(null);
             }
             $cmd->save();
             if (isset($command['value'])) {
                 $link_cmds[$cmd->getId()] = $command['value'];
             }
             $cmd_order++;
         } catch (Exception $exc) {
         }
     }
     if (count($link_cmds) > 0) {
         foreach ($this->getCmd() as $eqLogic_cmd) {
             foreach ($link_cmds as $cmd_id => $link_cmd) {
                 if ($link_cmd == $eqLogic_cmd->getName()) {
                     $cmd = cmd::byId($cmd_id);
                     if (is_object($cmd)) {
                         $cmd->setValue($eqLogic_cmd->getId());
                         $cmd->save();
                     }
                 }
             }
         }
     }
     $this->save();
     nodejs::pushUpdate('jeedom::alert', array('level' => 'warning', 'message' => ''));
 }
开发者ID:stef3569,项目名称:plugin-openzwave,代码行数:67,代码来源:openzwave.class.php


示例17: elseif

    echo "    <select class='formfld' name='default_setting_value'>\n";
    echo "    \t<option value='true' " . ($default_setting_value == "true" ? "selected='selected'" : null) . ">" . $text['label-true'] . "</option>\n";
    echo "    \t<option value='false' " . ($default_setting_value == "false" ? "selected='selected'" : null) . ">" . $text['label-false'] . "</option>\n";
    echo "    </select>\n";
} elseif ($category == "voicemail" && $subcategory == "voicemail_file" && $name == "text") {
    echo "    <select class='formfld' name='default_setting_value'>\n";
    echo "    \t<option value='listen' " . ($default_setting_value == "listen" ? "selected='selected'" : null) . ">" . $text['option-voicemail_file_listen'] . "</option>\n";
    echo "    \t<option value='link' " . ($default_setting_value == "link" ? "selected='selected'" : null) . ">" . $text['option-voicemail_file_link'] . "</option>\n";
    echo "    \t<option value='attach' " . ($default_setting_value == "attach" ? "selected='selected'" : null) . ">" . $text['option-voicemail_file_attach'] . "</option>\n";
    echo "    </select>\n";
} elseif ($category == "voicemail" && $subcategory == "keep_local" && $name == "boolean") {
    echo "\t<select class='formfld' name='default_setting_value'>\n";
    echo "    \t<option value='true' " . ($default_setting_value == "true" ? "selected='selected'" : null) . ">" . $text['label-true'] . "</option>\n";
    echo "    \t<option value='false' " . ($default_setting_value == "false" ? "selected='selected'" : null) . ">" . $text['label-false'] . "</option>\n";
    echo "\t</select>\n";
} elseif (is_json($default_setting_value)) {
    echo "\t<textarea class='formfld' style='width: 100%; height: 80px; font-family: courier; white-space: nowrap; overflow: auto;' name='default_setting_value' wrap='off'>" . $default_setting_value . "</textarea>\n";
} else {
    echo "\t<input class='formfld' type='text' name='default_setting_value' value=\"" . htmlspecialchars($default_setting_value) . "\">\n";
}
echo "<br />\n";
echo $text['description-value'] . "\n";
echo "</td>\n";
echo "</tr>\n";
if ($name == "array" || $name == '') {
    echo "<tr>\n";
    echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap' width='30%'>\n";
    echo "    " . $text['label-order'] . "\n";
    echo "</td>\n";
    echo "<td class='vtable' align='left'>\n";
    echo "\t<select name='default_setting_order' class='formfld'>\n";
开发者ID:reliberate,项目名称:fusionpbx,代码行数:31,代码来源:default_setting_edit.php


示例18: Exception

     }
     ajax::success($return);
 }
 if (init('action') == 'autoCompleteGroup') {
     if (!isConnect('admin')) {
         throw new Exception(__('401 - Accès non autorisé', __FILE__));
     }
     $return = array();
     foreach (scenario::listGroup(init('term')) as $group) {
         $return[] = $group['group'];
     }
     ajax::success($return);
 }
 if (init('action') == 'toHtml') {
     if (init('id') == 'all' || is_json(init('id'))) {
         if (is_json(init('id'))) {
             $scenario_ajax = json_decode(init('id'), true);
             $scenarios = array();
             foreach ($scenario_ajax as $id) {
                 $scenarios[] = scenario::byId($id);
             }
         } else {
             $scenarios = scenario::all();
         }
         $return = array();
         foreach ($scenarios as $scenario) {
             if ($scenario->getIsVisible() == 1) {
                 $return[$scenario->getId()] = $scenario->toHtml(init('version'));
             }
         }
         ajax::success($return);
开发者ID:GaelGRIFFON,项目名称:core,代码行数:31,代码来源:scenario.ajax.php


示例19: getUsbMapping

 public static function getUsbMapping($_name = '', $_getGPIO = false)
 {
     $cache = cache::byKey('jeedom::usbMapping');
     if (!is_json($cache->getValue()) || $_name == '') {
         $usbMapping = array();
         foreach (ls('/dev/', 'ttyUSB*') as $usb) {
             $vendor = '';
             $model = '';
             foreach (explode("\n", shell_exec('/sbin/udevadm info --name=/dev/' . $usb . ' --query=all')) as $line) {
                 if (strpos($line, 'E: ID_MODEL=') !== false) {
                     $model = trim(str_replace(array('E: ID_MODEL=', '"'), '', $line));
                 }
                 if (strpos($line, 'E: ID_VENDOR=') !== false) {
                     $vendor = trim(str_replace(array('E: ID_VENDOR=', '"'), '', $line));
                 }
             }
             if ($vendor == '' && $model == '') {
                 $usbMapping['/dev/' . $usb] = '/dev/' . $usb;
             } else {
                 $name = trim($vendor . ' ' . $model);
                 $number = 2;
                 while (isset($usbMapping[$name])) {
                     $name = trim($vendor . ' ' . $model . ' ' . $number);
                     $number++;
                 }
                 $usbMapping[$name] = '/dev/' . $usb;
             }
         }
         if ($_getGPIO) {
             if (file_exists('/dev/ttyAMA0')) {
                 $usbMapping['Raspberry pi'] = '/dev/ttyAMA0';
             }
             if (file_exists('/dev/ttymxc0')) {
                 $usbMapping['Jeedom board'] = '/dev/ttymxc0';
             }
             if (file_exists('/dev/S2')) {
                 $usbMapping['Banana PI'] = '/dev/S2';
             }
             if (file_exists('/dev/ttyS2')) {
                 $usbMapping['Banana PI (2)'] = '/dev/ttyS2';
             }
             if (file_exists('/dev/ttyS0')) {
                 $usbMapping['Cubiboard'] = '/dev/ttyS0';
             }
             foreach (ls('/dev/', 'ttyACM*') as $value) {
                 $usbMapping['/dev/' . $value] = '/dev/' . $value;
             }
         }
         cache::set('jeedom::usbMapping', json_encode($usbMapping), 0);
     } else {
         $usbMapping = json_decode($cache->getValue(), true);
     }
     if ($_name != '') {
         if (isset($usbMapping[$_name])) {
             return $usbMapping[$_name];
         }
         $usbMapping = self::getUsbMapping('', $_getGPIO);
         if (isset($usbMapping[$_name])) {
             return $usbMapping[$_name];
         }
         if (file_exists($_name)) {
             return $_name;
         }
         return '';
     }
     return $usbMapping;
 }
开发者ID:GaelGRIFFON,项目名称:core,代码行数:67,代码来源:jeedom.class.php


示例20: getTranslation

 public function getTranslation($_language)
 {
     $dir = dirname(__FILE__) . '/../../plugins/' . $this->getId() . '/core/i18n';
     if (!file_exists($dir)) {
         @mkdir($dir, 0775, true);
     }
     if (!file_exists($dir)) {
         return array();
     }
     if (file_exists($dir . '/' . $_language . '.json')) {
         $return = file_get_contents($dir . '/' . $_language . '.json');
         if (is_json($return)) {
             return json_decode($return, true);
         } else {
             return array();
         }
     }
     return array();
 }
开发者ID:saez0pub,项目名称:core,代码行数:19,代码来源:plugin.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_jumbo_capable函数代码示例发布时间:2022-05-15
下一篇:
PHP is_item_normal函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap