tyzw.net
当前位置:首页 >> php json解析 >>

php json解析

$jsonStr = '{"msg":{"auth":"Yes_auth","ddid":"1","payje":0.3,"payzt":"SUCCESS"}}';$arr = json_decode($jsonStr, true);$payzt = $arr['msg']['payzt'];// 或者$jsonStr = '{"msg":{"auth":"Yes_auth","ddid":"1","payje":0.3,"payzt":"SUC...

//读取json文件$json = file_get_contents('XXX.json');//json格式解析$arr = json_decode($json,true);

用json_decode()将json字符串转化成php数组,然后直接循环数组取出值即可。

$jsonStr = '{"msg":{"auth":"Yes_auth","ddid":"1","payje":0.3,"payzt":"SUCCESS"}}'; $arr = json_decode($jsonStr, true); $payzt = $arr['msg']['payzt']; // 或者 $jsonStr = '{"msg":{"auth":"Yes_auth","ddid":"1","payje":0.3,"payzt":...

$json=' {"name":"HBuilder","email":"hhhh@163.com","data":[{"name":"aaa","email":"aaaa@163.com","password":"kjkdsjfksd"},{"name":"bbb","email":"bbbb@163.com","password":"bbbb"}]}'$obj = json_decode($json);$data=$obj['data'];prin...

file_get_contents 得到的字符,使用 json_decode 解析成json。 $xxx_json = json_decode($xxx_response);

另外也可以像遍历数组一样遍历得到的对象。 另外通过json_decode获得的json对象,也可以通过"$jsonObj->a"这样的方式获取其值。

比如: $jsonData = '{"ErrorCode":0,"Success":true,"ErrMessage":"","HasData":true,"Records":[{"Time":"2014-08-19 07:47:10","Location":"广东省河源市G25黄田至义合高速路段","Reason":"驾驶中型以上载客载货汽车、危险物品运输车辆以外的...

你这个json转过来还是对象,直接转成数组就好取值了。 $arr = json_decode($str,1); // $str 代表json字符串 转成数组就可以随便取值了。 $lat = $arr['content']['location']['lat']; $ing= $arr['content']['location']['ing'];

网站首页 | 网站地图
All rights reserved Powered by www.tyzw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com