『壹』 php解析json數據
<?php
$json = '{"APPCount": 2,"data": [
{
"originalID": "991",
"APPName": "優酷",
"APPType": "APK",
"category": "視頻",
"versionName": "3.8",
"versionCode": "5",
"packageName ": "cn.dsp.youku",
" APPStatus": "待審核",
"testReportURL": "",
"downloadCount": 0
},
{
"originalID": "992",
"APPName": "優酷",
"APPType": "APK",
"category": "視頻",
"versionName": "3.8",
"versionCode": "5",
"packageName ": "cn.dsp.youku",
" APPStatus": "安全測評未通過",
"testReportURL": "http: //192.168.0.106: /SecurityTest/sdsd.pdf",
"downloadCount": 0
}
]
}';
$decode = json_decode($json,true);
echo $decode['data'][1]['testReportURL'];
『貳』 如何在PHP中解析json
給出例子供參考:
<?php
// Encode the data.
$json = json_encode(
array(
1 => array(
'English' => array(
'One',
'January'
),
'French' => array(
'Une',
'Janvier'
)
)
)
);
// Define the errors.
$constants = get_defined_constants(true);
$json_errors = array();
foreach ($constants["json"] as $name => $value) {
if (!strncmp($name, "JSON_ERROR_", 11)) {
$json_errors[$value] = $name;
}
}
// Show the errors for different depths.
foreach (range(4, 3, -1) as $depth) {
var_mp(json_decode($json, true, $depth));
echo 'Last error: ', $json_errors[json_last_error()], PHP_EOL, PHP_EOL;
}
?>
『叄』 如何在PHP中解析json
json_encode()
該函數主要用來將數組和對象,轉換為json格式。先看一個數組轉換的例子:
$arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
echo json_encode($arr);
『肆』 php 怎麼解釋返回的json數據
php 輸出JSON格式,使用json_encode函數即可 例如: 得到結果: {"fruits":{"a":"orange","b":"banana","c":"apple"},"numbers":[1,2,3,4,5,6],"holes":{"0":"first","5":"second","6":"third"}}
『伍』 PHP 如何解析 json
alert(send);
ajax=tel();
ajax.open("post", "setLine.class.php",true);
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
// 改成這樣就可以了
ajax.send({
'lineA':JSON.stringify(send);
});
『陸』 PHP解析JSON
echo$json->a[0]->date;
//數組和普通數組一樣,json對象使用對象序列化,上面的json意義上等價於():
classsubobj
{
var$date='20150101';
}
classobj
{
var$a=array(newsubobj());
}
$json=newobj();
『柒』 php 解析JSON
你看看這個例子:
<?php
$postArray ='[{"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:6:9","user":"000000000000000","time_stamp":1351587969902}, {"data":{"hello":"world"},"type":"1234","date":"2012-10-30 17:12:53","user":"000000000000000","time_stamp":1351588373519}]';
$de_json = json_decode($postArray,TRUE);
$count_json = count($de_json);
for ($i = 0; $i < $count_json; $i++)
{
//echo var_mp($de_json);
$dt_record = $de_json[$i]['date'];
$data_type = $de_json[$i]['type'];
$imei = $de_json[$i]['user'];
$message = json_encode($de_json[$i]['data']);
}
?>如果還有更多問題可以去後盾網論壇問題求助專區。
『捌』 PHP解析json
你得把 {"班級", A} 的 A 改成字串,變成這樣 {"班級", "A"}
不懂可以私信問我詳細
『玖』 如何在PHP中解析json
PHP裡面有json_encode(數組)可以把數組給轉換成JSON字元串,
而json_decode(JSON字元串,boolean)可以把JSON字元串轉換成數組或者對象類型,第二個參數boolean默認為false表示對象類型,true表示解析為數組類型通過下表訪問
『拾』 php如何解析json
用json_decode函數將json字元串轉換為數組
<?php
$json = '{"multi-i1ndex-style":{"old":{"0.1":"123","0.2":"234"}}}';
echo "<pre>";
print_r(json_decode($json, true));
echo "</pre>";