关于解析 json 无法解析
2014-11-10 19:47:31 +08:00
jy04149886
有一段json,用json_decode返回为null,请大神帮忙看一下
代码:$url=$_GET["url"];
$res = file_get_contents($url);
$res = json_decode($res,ture);
var_dump($res);
json:{
"currTime"
:
1415617116876, "result"
:
"1", "message"
:
"", "value"
:
{
"UserID"
:
"6e858035-083d-48b5-b822-74738e0d9434", "UserName"
:
"杨阳", "MobilePhone"
:
"18611645681", "UserAccount"
:
"18611645681", "Province"
:
"北京", "City"
:
"丰台区", "Sex"
:
"1", "IDSID"
:
"584b7781-7519-4f8e-91fb-e898e504bb1f", "IdsName"
:
"智信通演示专用(V5.1)", "SeviceName"
:
"", "SeviceTel"
:
"18611645681", "customerFlag"
:
"000", "platformFlag"
:
"ZXT", "invitedCode"
:
"RWZ", "ModifyTime"
:
1415592178000, "product"
:
[{
"SN": "18110515",
"snPwd": "18110515",
"IDC": "19110503937",
"CarTypeCode": "V",
"PlateNumber": "京N16Q96",
"LastServiceTime": "2014-11-10",
"MacAddress": "00:15:FF:F2:43:30",
"CarSerialName": "上海大众",
"SerialNumber": "110537",
"CarSerialID": "69912AAD-5992-490C-A9AD-ACAF16D20D8F",
"CarsModelID": "ae853982-3bce-4382-9296-fbc194ae6aaa",
"CarModelName": "新POLO",
"CarModelCode": "11",
"RegTime": 1415168103000,
"isSoundCard": 0,
"ProductName": "Tmt0N-Y05A智信通汽车远程体检系统",
"ProductCode": "F",
"isNewCar": 0,
"ModifyTime": 0,
"ERPdata": null,
"lastMileage": "5000.00",
"InsureDate": "",
"ProductId": "3b41064f-fc44-40c4-94b7-a27d10418f88",
"OrderTime": "",
"isClearCode": 1,
"isVoltageAlarm": 0,
"ProductModel": "C.Y.0005A",
"ServiceTel": null,
"isTTS": 0,
"isAccSensor": 0,
"engineNo": "",
"VIN": "",
"isGps": 0
}, {
"SN": "420003291",
"snPwd": "278953",
"IDC": "19420003291",
"CarTypeCode": "K",
"PlateNumber": "",
"LastServiceTime": "2014-11-10",
"MacAddress": "",
"CarSerialName": "北京现代",
"SerialNumber": "420003291",
"CarSerialID": "6D96C7FB-0DE2-4588-AFF3-299015E7D09A",
"CarsModelID": "04a20d34-6fe2-4af7-b46b-5caf8a2b65e7",
"CarModelName": "名图",
"CarModelCode": "13",
"RegTime": 1415587989000,
"isSoundCard": 0,
"ProductName": "Tmt0N-Y05D1W低脉冲 车联网系统V1.0",
"ProductCode": "W",
"isNewCar": 0,
"ModifyTime": 0,
"ERPdata": null,
"lastMileage": "",
"InsureDate": "",
"ProductId": "e01a1bef-37cf-4b73-920d-ab667d7aac41",
"OrderTime": "",
"isClearCode": 0,
"isVoltageAlarm": 0,
"ProductModel": "C.Y.0008E",
"ServiceTel": null,
"isTTS": 0,
"isAccSensor": 0,
"engineNo": "",
"VIN": "",
"isGps": 0
}, {
"SN": "40007499",
"snPwd": "585830",
"IDC": "19040007499",
"CarTypeCode": "V",
"PlateNumber": "",
"LastServiceTime": "2014-11-10",
"MacAddress": "00:15:FF:F3:A8:46",
"CarSerialName": "一汽-大众",
"SerialNumber": "040007499",
"CarSerialID": "15055F3D-57FD-4C87-A8AA-2173AF07C57A",
"CarsModelID": "8766dd1f-26d4-43ff-956a-68ee49ec92e2",
"CarModelName": "高尔夫6",
"CarModelCode": "8",
"RegTime": 1415591118000,
"isSoundCard": 1,
"ProductName": "Tmt0N-Y05A11WS智信通汽车远程体检系统",
"ProductCode": "X",
"isNewCar": 0,
"ModifyTime": 0,
"ERPdata": null,
"lastMileage": "",
"InsureDate": "",
"ProductId": "2994df09-45fe-45a9-8e6e-cd374a129b6b",
"OrderTime": "",
"isClearCode": 1,
"isVoltageAlarm": 0,
"ProductModel": "C.Y.0005D",
"ServiceTel": null,
"isTTS": 0,
"isAccSensor": 0,
"engineNo": "",
"VIN": "",
"isGps": 0
}]
}
}
4 条回复
kofj
2014-11-10 20:51:48 +08:00
jy04149886
2014-11-10 21:05:21 +08:00
返回空值、、、、貌似加一个mb_convert_encoding也许好用了。。。
tinyhill
2014-11-10 21:10:48 +08:00
字符串是不是 UTF-8 编码?PHP 要求字符串必须为 UTF-8 编码的,GBK 会反馈 null
jy04149886
2014-11-10 21:34:26 +08:00
谢啦,我用的转换函数,貌似可以了。。。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/145433
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.