"Response":{
"Head":{
"ChuFaZhan":{
"CheZhanBianHao":"69eb262a-067b-4ad0-8b6e-c968358971e5",
"CheZhanBianMa":"1777018410",
"CheZhanMingCheng":"济南"
},
"DaoDaZhan":{
"CheZhanBianHao":"3e8b13db-f1ad-459d-97c2-02838c92293c",
"CheZhanBianMa":"1049301979",
"CheZhanMingCheng":"乌鲁木齐"
}
},
"Main":{
"@Rows":"2",
"Item":[
{
"@Id":"1",
"CheCiBianHao":"508f7049-ad1f-493b-9955-5ed51dc7b1f1",
"CheCiBianMa":"1351577673",
"CheCiMingCheng":"L207",
"CheXingMingCheng":"普快",
"ShiFaZhan":"济南",
"ChuFaZhan":"济南",
"DaoDaZhan":"乌鲁木齐",
"ZhongDianZhan":"乌鲁木齐",
"FaShi":"05:00",
"DaoShi":"15:06",
"LiShi":"58:06",
"LiCheng":"0",
},
{
"@Id":"2",
"CheCiBianHao":"b9f3f9de-eb0e-47b5-8cbf-d0451cc2acca",
"CheCiBianMa":"1175193122",
"CheCiMingCheng":"1085",
"CheXingMingCheng":"普快",
"ShiFaZhan":"济南",
"ChuFaZhan":"济南",
"DaoDaZhan":"乌鲁木齐",
"ZhongDianZhan":"乌鲁木齐",
"FaShi":"09:20",
"DaoShi":"10:11",
"LiShi":"48:51",
"LiCheng":"0",
}
]
}
}
}
这样一个json,请问怎么样能取到Head中ChuFaZhan中CheZhanMingCheng的值和Main中Item中ChuFaZhan的值,出发站这个值是循环输出的
1 个解决方案
#1
$jsp = '{
"Response":{
"Head":{
"ChuFaZhan":{
"CheZhanBianHao":"69eb262a-067b-4ad0-8b6e-c968358971e5",
"CheZhanBianMa":"1777018410",
"CheZhanMingCheng":"济南"
},
"DaoDaZhan":{
"CheZhanBianHao":"3e8b13db-f1ad-459d-97c2-02838c92293c",
"CheZhanBianMa":"1049301979",
"CheZhanMingCheng":"乌鲁木齐"
}
},
"Main":{
"@Rows":"2",
"Item":[
{
"@Id":"1",
"CheCiBianHao":"508f7049-ad1f-493b-9955-5ed51dc7b1f1",
"CheCiBianMa":"1351577673",
"CheCiMingCheng":"L207",
"CheXingMingCheng":"普快",
"ShiFaZhan":"济南",
"ChuFaZhan":"济南",
"DaoDaZhan":"乌鲁木齐",
"ZhongDianZhan":"乌鲁木齐",
"FaShi":"05:00",
"DaoShi":"15:06",
"LiShi":"58:06",
"LiCheng":"0"
},
{
"@Id":"2",
"CheCiBianHao":"b9f3f9de-eb0e-47b5-8cbf-d0451cc2acca",
"CheCiBianMa":"1175193122",
"CheCiMingCheng":"1085",
"CheXingMingCheng":"普快",
"ShiFaZhan":"济南",
"ChuFaZhan":"济南",
"DaoDaZhan":"乌鲁木齐",
"ZhongDianZhan":"乌鲁木齐",
"FaShi":"09:20",
"DaoShi":"10:11",
"LiShi":"48:51",
"LiCheng":"0"
}
]
}
}
}';
$jsp_arr = json_decode($jsp);
var_dump($jsp_arr->Response->Head->ChuFaZhan->CheZhanMingCheng);
var_dump($jsp_arr->Response->Main->Item[0]->ChuFaZhan);
#1
$jsp = '{
"Response":{
"Head":{
"ChuFaZhan":{
"CheZhanBianHao":"69eb262a-067b-4ad0-8b6e-c968358971e5",
"CheZhanBianMa":"1777018410",
"CheZhanMingCheng":"济南"
},
"DaoDaZhan":{
"CheZhanBianHao":"3e8b13db-f1ad-459d-97c2-02838c92293c",
"CheZhanBianMa":"1049301979",
"CheZhanMingCheng":"乌鲁木齐"
}
},
"Main":{
"@Rows":"2",
"Item":[
{
"@Id":"1",
"CheCiBianHao":"508f7049-ad1f-493b-9955-5ed51dc7b1f1",
"CheCiBianMa":"1351577673",
"CheCiMingCheng":"L207",
"CheXingMingCheng":"普快",
"ShiFaZhan":"济南",
"ChuFaZhan":"济南",
"DaoDaZhan":"乌鲁木齐",
"ZhongDianZhan":"乌鲁木齐",
"FaShi":"05:00",
"DaoShi":"15:06",
"LiShi":"58:06",
"LiCheng":"0"
},
{
"@Id":"2",
"CheCiBianHao":"b9f3f9de-eb0e-47b5-8cbf-d0451cc2acca",
"CheCiBianMa":"1175193122",
"CheCiMingCheng":"1085",
"CheXingMingCheng":"普快",
"ShiFaZhan":"济南",
"ChuFaZhan":"济南",
"DaoDaZhan":"乌鲁木齐",
"ZhongDianZhan":"乌鲁木齐",
"FaShi":"09:20",
"DaoShi":"10:11",
"LiShi":"48:51",
"LiCheng":"0"
}
]
}
}
}';
$jsp_arr = json_decode($jsp);
var_dump($jsp_arr->Response->Head->ChuFaZhan->CheZhanMingCheng);
var_dump($jsp_arr->Response->Main->Item[0]->ChuFaZhan);