本文整理汇总了PHP中jsonDecode函数的典型用法代码示例。如果您正苦于以下问题:PHP jsonDecode函数的具体用法?PHP jsonDecode怎么用?PHP jsonDecode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了jsonDecode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dataDecode
function dataDecode($type, $dataJson)
{
$decodeJson = jsonDecode($dataJson);
if (in_array($type, array(1, 4))) {
$keyNameList = array('dlrNo' => '专营店编号', 'activityName' => '活动主题', 'activityAddress' => '活动地址', 'activityTime' => '活动时间段', 'activityType' => '活动类型', 'activityCost' => '<font color="blue">活动额度</font>', 'budgetApply' => '<font color="blue">预算总费用</font>', 'orderStatus' => '站点状态', 'siteSpecs' => '巡展类型标志', 'settleApply' => '<font color="blue">结算申请总费用</font>', 'clearingPath' => '结算凭证', 'kpi' => 'KPI系数', 'settleMoney' => '结算金额');
$valueList = array();
foreach ($decodeJson as $k => $v) {
if (isset($keyNameList[$k])) {
$valueList[] = $keyNameList[$k] . ':"' . $v . '"';
}
}
return implode(',', $valueList);
} elseif (in_array($type, array(2, 5))) {
$keyNameList = array('adType' => '媒体类型', 'adName' => '媒体名称', 'adSpecification' => '投放规格', 'adTime' => '发布时间段', 'adCount' => '发布频次', 'budgetApply' => '<font color="blue">预计费用</font>', 'settleApply' => '<font color="blue">实际费用</font>');
$valueList = array();
foreach ($decodeJson as $k => $v) {
if (isset($keyNameList[$k])) {
$valueList[] = $keyNameList[$k] . ':"' . $v . '"';
}
}
return implode(';', $valueList);
} elseif (in_array($type, array(3, 6))) {
$keyNameList = array('activityAddress' => '活动地址', 'activityTime' => '活动时间段', 'budgetApply' => '<font color="blue">预计费用</font>', 'settleApply' => '<font color="blue">实际费用</font>');
$keyNameList2 = array('detailType' => '费用明细类型', 'detailName' => '费用明细名称', 'detailTime' => '活动时间段', 'budgetApply' => '<font color="blue">预计费用</font>', 'settleApply' => '<font color="blue">实际费用</font>');
$xunDetailType = $this->config->item('xunDetailType');
$xunDetailName = $this->config->item('xunDetailName');
$valueList = array();
foreach ($decodeJson as $k => $v) {
if (isset($keyNameList[$k])) {
$valueList[] = $keyNameList[$k] . ':"' . $v . '"';
}
}
$valueList2 = array();
if (isset($decodeJson->detailData)) {
foreach ($decodeJson->detailData as $k => $v) {
$valueList3 = array();
foreach ($v as $kk => $vv) {
if (isset($keyNameList2[$kk])) {
if ($kk == 'detailType') {
$vv = isset($xunDetailType[$vv]) ? $xunDetailType[$vv] : '';
}
if ($kk == 'detailName') {
$vv = isset($xunDetailName[$decodeJson->detailData[0]->detailType][$vv]) ? $xunDetailName[$decodeJson->detailData[0]->detailType][$vv] : '';
}
$valueList3[] = $keyNameList2[$kk] . ':"' . $vv . '"';
}
}
$valueList2[] = implode(';', $valueList3);
}
}
$valueList[] = '<br><font color="blue">线下活动明细:</font><br>' . implode('<br>', $valueList2);
return implode(';', $valueList);
}
return '';
}
示例2: JSON_RFC
function JSON_RFC($jsonRequest)
{
$rfc = jsonDecode($jsonRequest);
$rfc_data = new stdClass();
if (is_string($rfc->rfc_session) && is_string($rfc->rfc_object) && is_string($rfc->rfc_method) && isset($rfc->rfc_data)) {
$this->rfc_session = $rfc->rfc_session;
$this->rfc_object = $rfc->rfc_object;
$this->rfc_method = $rfc->rfc_method;
$this->rfc_data = $rfc->rfc_data;
} elseif (is_string($rfc->rfc_session) && is_string($rfc->rfc_object) && is_string($rfc->rfc_method) && isset($rfc->query_string)) {
$this->rfc_session = $rfc->rfc_session;
$this->rfc_object = $rfc->rfc_object;
$this->rfc_method = $rfc->rfc_method;
$this->query_string = $rfc->query_string;
}
}
示例3: testJsonDecodeLint
public function testJsonDecodeLint()
{
$expected = <<<EOT
Parse error on line 1:
{"a": {[]}
------^
Expected one of: 'STRING', '}'
EOT;
try {
$str = jsonDecode('{"a": {[]}', false, 512, 0, false, true);
} catch (Exception\JsonDecodeException $e) {
self::assertEquals($expected, $e->getData()['errDetail']);
$err = $e;
}
self::assertInstanceOf('Keboola\\Utils\\Exception\\JsonDecodeException', $err);
}
示例4: getErrorHtml
function getErrorHtml($errorFilename, $offset = 1)
{
$errorMessage = readTemporaryFile($errorFilename);
if ($errorMessage != "") {
$errInfo = jsonDecode($errorMessage);
$errhtml = "<a href='#' id='errorClick'>Show/Hide errors and warnings</a>";
$errhtml .= "<div id='errorRow' colspan='3' >";
// style='display:none'
if ($errInfo == null) {
$errhtml .= "Couldn't read results from the Umple compiler!";
} else {
$results = $errInfo["results"];
foreach ($results as $result) {
$url = $result["url"];
$line = intval($result["line"]) - $offset;
$errorCode = $result["errorCode"];
$severityInt = intval($result["severity"]);
if ($severityInt > 2) {
$severity = "Warning";
$textcolor = "<font color=\"black\">";
} else {
$severity = "Error";
$textcolor = "<font color=\"red\">";
}
$msg = htmlspecialchars($result["message"]);
$errhtml .= $textcolor . " {$severity} on <a href=\"javascript:Action.setCaretPosition({$line});Action.updateLineNumberDisplay();\">line {$line}</a> : {$msg}.</font> <i><a href=\"{$url}\" target=\"helppage\">More information ({$errorCode})</a></i></br>";
}
}
$errhtml .= "</div>";
$errhtml .= "<script type=\"text/javascript\">jQuery(\"#errorClick\").click(function(a){a.preventDefault();jQuery(\"#errorRow\").toggle();});</script>";
return $errhtml;
}
return "";
}
示例5: foreach
<div style="width:100px; float:left;">Privacy</div>
<div style="width:100px; float:left;">Date Created</div>
<br clear="all" />
</div>';
foreach ($flix as $k => $v) {
$privacy = '';
if ($v['us_privacy'] & PERM_SLIDESHOW_PUBLIC == PERM_SLIDESHOW_PUBLIC) {
$privacy .= 'Public ';
}
if ($v['us_privacy'] & PERM_SLIDESHOW_COMMENT == PERM_SLIDESHOW_COMMENT) {
$privacy .= 'Comment ';
}
if ($privacy == '') {
$privacy = 'Private';
}
$settings = jsonDecode($v['us_settings']);
$theme = 'Default Left-Right';
$preview = false;
$altTheme = '';
$mp3 = 'No Music';
foreach ($settings as $v2) {
if ($v2['instanceName_str'] == 'background_mc') {
if (isset($v2['swfPath_str'])) {
$theme = basename($v2['swfPath_str']);
}
}
if ($v2['instanceName_str'] == 'backgroundGraphic_mc') {
if (isset($v2['swfPath_str'])) {
$altTheme = basename($v2['swfPath_str']);
}
}
示例6: array
$filterNames = array('' => translate('ChooseFilter'));
foreach (dbFetchAll("select * from Filters order by Name") as $row) {
$filterNames[$row['Name']] = $row['Name'];
if ($row['Background']) {
$filterNames[$row['Name']] .= "*";
}
if (!empty($_REQUEST['reload']) && isset($_REQUEST['filterName']) && $_REQUEST['filterName'] == $row['Name']) {
$dbFilter = $row;
}
}
$backgroundStr = "";
if (isset($dbFilter)) {
if ($dbFilter['Background']) {
$backgroundStr = '[' . strtolower(translate('Background')) . ']';
}
$_REQUEST['filter'] = jsonDecode($dbFilter['Query']);
$_REQUEST['sort_field'] = isset($_REQUEST['filter']['sort_field']) ? $_REQUEST['filter']['sort_field'] : "DateTime";
$_REQUEST['sort_asc'] = isset($_REQUEST['filter']['sort_asc']) ? $_REQUEST['filter']['sort_asc'] : "1";
$_REQUEST['limit'] = isset($_REQUEST['filter']['limit']) ? $_REQUEST['filter']['limit'] : "";
unset($_REQUEST['filter']['sort_field']);
unset($_REQUEST['filter']['sort_asc']);
unset($_REQUEST['filter']['limit']);
}
$conjunctionTypes = array('and' => translate('ConjAnd'), 'or' => translate('ConjOr'));
$obracketTypes = array();
$cbracketTypes = array();
if (isset($_REQUEST['filter']['terms'])) {
for ($i = 0; $i <= count($_REQUEST['filter']['terms']) - 2; $i++) {
$obracketTypes[$i] = str_repeat("(", $i);
$cbracketTypes[$i] = str_repeat(")", $i);
}
示例7: ueditor
/**
* 百度上传控制
*/
function ueditor()
{
//验证用户登录状态
$this->load->library('User', null, 'userLib');
$this->user = $this->userLib->getUserInfo();
if (!$this->user) {
$result = jsonEncode(array('state' => $this->userLib->error));
} else {
$CONFIG = jsonDecode(preg_replace("/\\/\\*[\\s\\S]+?\\*\\//", "", file_get_contents(FCPATH . "/../public/ueditor/php/config.json")), true);
$action = $_GET['action'];
switch ($action) {
case 'config':
$result = jsonEncode($CONFIG);
break;
/* 上传图片 */
/* 上传图片 */
case 'uploadimage':
/* 上传涂鸦 */
/* 上传涂鸦 */
case 'uploadscrawl':
/* 上传视频 */
/* 上传视频 */
case 'uploadvideo':
/* 上传文件 */
/* 上传文件 */
case 'uploadfile':
$uploadInfo = (include FCPATH . "/../public/ueditor/php/action_upload.php");
$resultArr = jsonDecode($uploadInfo);
$this->load->model('fileModel');
$fileData = array('dir' => str_replace('upload', '', $action), 'fileName' => $resultArr['title'], 'fileType' => $resultArr['type'], 'fileSize' => $resultArr['size'], 'origName' => $resultArr['original'], 'viewPath' => $resultArr['url'], 'fullPath' => $resultArr['filePath'], 'userId' => (int) $this->user['userId'], 'createTime' => time());
$fileId = $this->fileModel->add($fileData);
$resultArr['fileId'] = $fileId;
$result = jsonEncode($resultArr);
break;
/* 列出图片 */
/* 列出图片 */
case 'listimage':
// $result = include(FCPATH . "/../public/ueditor/php/action_list.php");
$this->load->model('fileModel');
$fileList = $this->fileModel->getList(array('userId' => (int) $this->user['userId'], 'dir' => 'image'));
$result = array('state' => 'SUCCESS', 'start' => 0, 'total' => count($fileList), 'list' => array());
foreach ($fileList as $v) {
$result['list'][] = array('fileId' => (int) $v['id'], 'url' => $v['viewPath'], 'mtime' => (int) $v['createTime']);
}
$result = jsonEncode($result);
break;
/* 列出文件 */
/* 列出文件 */
case 'listfile':
// $result = include(FCPATH . "/../public/ueditor/php/action_list.php");
$this->load->model('fileModel');
$fileList = $this->fileModel->getList(array('userId' => (int) $this->user['userId'], 'dir' => 'file'));
$result = array('state' => 'SUCCESS', 'start' => 0, 'total' => count($fileList), 'list' => array());
foreach ($fileList as $v) {
$result['list'][] = array('fileId' => (int) $v['id'], 'url' => $v['viewPath'], 'mtime' => (int) $v['createTime']);
}
$result = jsonEncode($result);
break;
/* 抓取远程文件 */
/* 抓取远程文件 */
case 'catchimage':
$uploadInfo = (include FCPATH . "/../public/ueditor/php/action_crawler.php");
$resultArr = jsonDecode($uploadInfo);
$this->load->model('fileModel');
$fileData = array('dir' => str_replace('upload', '', $action), 'fileName' => $resultArr['title'], 'fileType' => $resultArr['type'], 'fileSize' => $resultArr['size'], 'origName' => $resultArr['original'], 'viewPath' => $resultArr['url'], 'fullPath' => $resultArr['filePath'], 'userId' => (int) $this->user['userId'], 'createTime' => time());
$fileId = $this->fileModel->add($fileData);
$resultArr['fileId'] = $fileId;
$result = jsonEncode($resultArr);
break;
default:
$result = jsonEncode(array('state' => '请求地址出错'));
break;
}
}
/* 输出结果 */
if (isset($_GET["callback"])) {
if (preg_match("/^[\\w_]+\$/", $_GET["callback"])) {
echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
} else {
echo jsonEncode(array('state' => 'callback参数不合法'));
}
} else {
echo $result;
}
}
示例8: jsonDecode
$fields = jsonDecode($_POST["fields"]);
$cursor = $mongocollection->find($query, $fields);
} else {
$cursor = $mongocollection->find($query);
}
if (!isset($cursor)) {
error("Could not execute query", $mongodb->lastError());
}
if (isset($_POST["limit"])) {
$cursor->limit($_POST["limit"] * 1);
}
if (isset($_POST["skip"])) {
$cursor->skip($_POST["skip"] * 1);
}
if (isset($_POST["sort"])) {
$val = jsonDecode($_POST["sort"]);
$cursor->sort($val);
}
if ($subcommand == "explain") {
$result = $cursor->explain();
} else {
if ($subcommand == "validate") {
if ($cursor->hasNext()) {
$cursor->getNext();
}
$result = $cursor->valid();
} else {
if ($subcommand == "count") {
$result = $cursor->count();
} else {
$result = $cursor;
示例9: isDataTypeNumeric
function isDataTypeNumeric($type)
{
global $MYSQL_DATA_TYPE;
if (@is_file(PATH_MYSQL_DATA_TYPE) && count($MYSQL_DATA_TYPE) <= 0) {
$json = jsonDecode(@file_get_contents(PATH_MYSQL_DATA_TYPE), true);
if ($json != null && count($json) > 0) {
$MYSQL_DATA_TYPE = $json;
}
}
if ($MYSQL_DATA_TYPE != null && is_array($MYSQL_DATA_TYPE)) {
return in_array(strtoupper($type), $MYSQL_DATA_TYPE['data']['Numeric']);
} else {
return false;
}
}
示例10: sendData
/**
* 发送数据
*/
function sendData($dataType = 'sum')
{
$accessToken = $this->getAccessToken();
$urlParams = array('mainCmd' => $this->mainCmdList[$dataType], 'accessToken' => $accessToken);
$url = $this->apiUrl . $this->apiExtList[$dataType] . '?' . httpBuildQuery($urlParams);
$data = array('params' => $this->data);
$returnData = $this->httpGet($url, jsonEncode($data), array('Content-Type: application/json'));
$jsonData = jsonDecode($returnData);
//var_dump($jsonData);
//exit();
//提交成功
if (isset($jsonData['authcHead']) && $jsonData['authcHead']['retnCode'] == 0) {
return true;
} else {
return false;
}
}
示例11: count
$proUsersYearlyCount = $proUsersYearly['CNT'];
$proUsersCount = $proUsersMonthlyCount + $proUsersYearlyCount;
$personalUsersMonthlyCount = $personalUsersMonthly['CNT'];
$personalUsersYearlyCount = $personalUsersYearly['CNT'];
$personalUsersCount = $personalUsersMonthlyCount + $personalUsersYearlyCount;
$conversions = $proUsersCount + $personalUsersCount;
$personalConversionRate = 0;
$proConversionRate = 0;
$totalConversionRate = 0;
$slideshowsCount = count($slideshows);
// loop through every slideshow
// loop through each of its elements if they exist
// if it contains a hotspot, add to the hotspot total and go to the next slideshow (break out of the elements for loop)
$hotspots = 0;
foreach ($slideshows as $vSlideshow) {
$elementsArr = jsonDecode($vSlideshow['us_elements']);
if (is_array($elementsArr)) {
foreach ($elementsArr as $v2) {
if (is_array($v2)) {
// if hotspots exist
if (array_key_exists('hotSpot_arr', $v2)) {
// this slideshow has a hotspot
$hotspots++;
break;
}
}
}
}
}
// graph stuff
$graphArray['personal'][$k] = $regPersonalCount;
示例12: firstPhoto
function firstPhoto($identifier = false)
{
if (strlen($identifier) == 32) {
$sql = 'SELECT us_elements AS US_ELEMENTS ' . 'FROM user_slideshows ' . 'WHERE us_key = ' . $this->dbh->sql_safe($identifier) . ' ';
$data = $this->dbh->query_first($sql);
} else {
$data['US_ELEMENTS'] = $identifier;
}
$elements = jsonDecode($data['US_ELEMENTS']);
// loop through the elements array
// if $v['thumbnailPath_str'] is not blank
// then return that element
if (is_array($elements)) {
foreach ($elements as $k => $v) {
if (isset($v['photoId_int'])) {
return $v;
}
}
}
return false;
}
示例13: array
// Get all the slideshow elements from old
$sql = 'SELECT ufd.ufd_up_id AS UFD_UP_ID, ufd.ufd_delay AS UFD_DELAY, ufd.ufd_isTitle AS UFD_IS_TITLE, ufd.ufd_name AS UFD_NAME, ufd.ufd_description AS UFD_DESC ' . 'FROM ' . $oldDB . '.user_fotoflix_data AS ufd ' . 'WHERE ufd.ufd_uf_id = ' . $v['UF_ID'] . ' ' . 'ORDER BY ufd.ufd_order ';
$elements_rs = $GLOBALS['dbh']->query_all($sql);
// Create the new elements
$elements = array();
$photoPath_str = '';
$photoKey_str = '';
$photoId_int = 0;
$thumbnailPath_str = '';
$description_str = '';
$delay_int = 0;
$tags_str = '';
$width_int = 0;
$height_int = 0;
$rotation_int = 0;
$themeAr = jsonDecode($themes[$v['UF_TEMPLATE']]);
if ($v['UF_CREATED_BY'] !== null) {
echo 'Created By Title Frame<br />';
// set title frame
$delay_int = 3000;
foreach ($themeAr as $v3) {
if ($v3['instanceName_str'] == 'title_mc') {
$swfPath_str = $v3['swfPath_str'];
break;
}
}
$title_str = "Created by\n" . xmlUnSafe($v['UF_CREATED_BY']);
$mainColor_str = $settings[0]['highlightColor_str'];
$backgroundColor_str = $settings[0]['backgroundColor_str'];
$elements[] = array('delay_int' => $delay_int, 'swfPath_str' => $swfPath_str, 'title_str' => $title_str, 'mainColor_str' => $mainColor_str, 'backgroundColor_str' => $backgroundColor_str);
}
示例14: basename
<div style="float:left; width:20px; text-align:right;">' . $place . '. </div>
<div style="float:left; padding-left:5px;">' . basename($v) . '</div>
<br clear="all" />
</div>';
$place++;
}
echo ' </div>
<br clear="all" />
</div>';
// slideshows
$sql = 'SELECT * ' . 'FROM user_slideshows AS us ' . 'WHERE us_status = \'active\' ';
$slideshows = $GLOBALS['dbh']->query_all($sql);
// get all the settings arrays for all the slideshows
$settingsArr = array();
foreach ($slideshows as $k => $v) {
$settingsArr[] = jsonDecode($v['us_settings']);
}
// go through each slideshows settings to get the themes
$themesArr = array();
foreach ($settingsArr as $thisSettings) {
$currentTheme = 'Default Left-Right';
$preview = false;
$altTheme = '';
foreach ($thisSettings as $v) {
if ($v['instanceName_str'] == 'background_mc') {
if (isset($v['swfPath_str'])) {
$currentTheme = $v['swfPath_str'];
}
}
if ($v['instanceName_str'] == 'backgroundGraphic_mc') {
if (isset($v['swfPath_str'])) {
示例15: isset
<?php
$fl =& CFlix::getInstance();
$key = isset($_GET['key']) ? $_GET['key'] : false;
$slide = isset($_GET['slide']) ? $_GET['slide'] : 0;
$slideshowData = $fl->search(array('KEY' => $key));
$elementsArr = jsonDecode($slideshowData['US_ELEMENTS']);
// if we have a correct slide number
if (count($elementsArr) > 0 && $slide < count($elementsArr)) {
// if it's a photo/title/unknown
if (array_key_exists('photoPath_str', $elementsArr[$slide])) {
$img = dynamicImageLock($elementsArr[$slide]['thumbnailPath_str'], $elementsArr[$slide]['photoKey_str'], $elementsArr[$slide]['rotation_int'], $elementsArr[$slide]['width_int'], $elementsArr[$slide]['height_int'], 500, 375);
echo '<div id="_currentSlide" style="float:left; padding-right:10px;"><img src="' . $img[0] . '" border="0" width="' . $img[1] . '" height="' . $img[2] . '" /></div>';
$html = '';
// if hotspots exist
if (array_key_exists('hotSpot_arr', $elementsArr[$slide])) {
$html .= '<div style="padding-top:10px;">Hotspots on this photo:</div>';
foreach ($elementsArr[$slide]['hotSpot_arr'] as $k => $v) {
switch ($v['swfPath_str']) {
case 'quote.swf':
$html .= '<div><img src="images/html_slideshow/chat.png" class="png" border="0" width="16" height="16" style="margin:5px 5px 0px 10px;" />"' . $v['note_str'] . '"</div>';
break;
case 'eye_blood_shot.swf':
$html .= '<div><img src="images/html_slideshow/bloodshot_eye.png" class="png" border="0" width="16" height="16" style="margin:5px 5px 0px 10px;" />Bloodshot eye</div>';
break;
case 'eye.swf':
$html .= '<div><img src="images/html_slideshow/eye.png" class="png" border="0" width="16" height="16" style="margin:5px 5px 0px 10px;" />Eye</div>';
break;
case 'hair1.swf':
$html .= '<div><img src="images/html_slideshow/fro.png" class="png" border="0" width="16" height="16" style="margin:5px 5px 0px 10px;" />Fro hair</div>';
break;