gpt4 book ai didi

php - JSON解码未显示所有数据PHP

转载 作者:行者123 更新时间:2023-12-04 04:32:33 25 4
gpt4 key购买 nike

我正在尝试用 PHP 解码 JSON 文件(我一直在这样做)。但是当我尝试使用这个文件时:https://www.hyzyne.co.nz/updatewlg/nzta.json .它对其进行解码,但只显示数组中 JSON 的最后一部分。

PHP:

$xml = file_get_contents('https://www.hyzyne.co.nz/updatewlg/nzta.json');

$data = json_decode($xml, true);

print_r($data);

如果您查看该文件,您会看到它很长。

当我打印上述所有内容时,我得到的是:
Array ( [data] => Array ( [0] => Array ( [roadevent] => Array ( [alternativeRoute] => Follow Detours [directLineDistance1] => 1.55 km southeast of Taradale [directLineDistance2] => 1.62 km southwest of Jervoistown [directLineDistance3] => 1.66 km east of Waiohiki [endDate] => 2013-12-03T18:25:18.677+13:00 [eventComments] => Now Clear [eventDescription] => Crash [eventId] => 84295 [eventIsland] => North Island [eventType] => Road Hazard [expectedResolution] => Until further notice [impact] => Caution [locationArea] => SH 50 Taradale [locations] => Array ( [location] => 050-0005/04.88 Taradale ) [planned] => false [startDate] => 2013-12-03T17:17:00.000+13:00 [status] => Resolved [wktGeometry] => SRID=27200;POINT (2841479.57385071 6176775.805777006) [eventCreated] => 2013-12-03T17:20:18.450+13:00 [eventModified] => 2013-12-03T18:25:18.380+13:00 [informationSource] => Police [supplier] => Official [eventRegions] => Array ( [eventRegion] => Taranaki, Manawatu-Wanganui, Hawke's Bay & Gisborne Region ) ) ) ) )

这不是 JSON 的全部,我确实自己制作了 JSON 文件。但我无法识别 JSON 中的任何问题。

即使将我的 JSON 通过 http://jsonlint.com/我只得到最后一段。有谁知道我做错了什么?

谢谢

最佳答案

你的 json 有问题。您正在重复属性“roadevent”。我假设他们都是 不应该包含在同一个对象中 {阵列内部 [ .

{
"data": [{
"roadevent": {
"alternativeRoute": "Local Roads",
"directLineDistance1": "1.43 km west of Heathcote Valley",
"directLineDistance2": "1.45 km southwest of Ferrymead",
"directLineDistance3": "1.68 km southwest of Mount Pleasant",
"eventComments": "Bridges Not To Be Crossed By Any Overweight Loads Except For Iso Containers Being Moved On Existing Overweight Permits. Any Other Overweight Loads (including Those Travelling On Area Permits) Will Be Considered On A Case By Case Basis.",
"eventDescription": "Other",
"eventId": "47078",
"eventIsland": "South Island",
"eventType": "Road Hazard",
"expectedResolution": "Until further notice",
"impact": "Vehicle Restrictions",
"locationArea": "SH 74 Christchurch - Tunnel Rd, Horotane Valley Overpasses No 1 And 2 (bsn 217 & 218)",
"locations": {
"location": "074-0019/02.60-D Heathcote Valley"
},
"planned": "false",
"restrictions": "Road constricted for oversize and non-standard vehicles",
"startDate": "2011-03-03T17:47:00.000+13:00",
"status": "Active",
"wktGeometry": "SRID=27200;POINT (2485362.087794318 5737151.779842964)",
"eventCreated": "2011-03-03T17:49:29.260+13:00",
"eventModified": "2012-08-15T17:52:54.210+12:00",
"informationSource": "NMC",
"supplier": "Official"
},
"roadevent": {
"alternativeRoute": "-",
"directLineDistance1": "0.69 km southwest of Hakataramea",
"directLineDistance2": "0.92 km northeast of Kurow",
"directLineDistance3": "6.43 km southeast of Lake Waitaki",
"eventComments": "Speed Restriction In Place For Heavy Vehicles Of 20kph.",
"eventDescription": "Other",
"eventId": "62595",
"eventIsland": "South Island",
"eventType": "Road Hazard",
"expectedResolution": "Until further notice",
"impact": "Caution",
"locationArea": "SH 82 Waitaki River Bridge No 1 ( Kurow Bridges)",
"locations": {
"location": "082-0053/16.68 -"
},
"planned": "false",
"startDate": "2012-06-14T12:17:00.000+12:00",
"status": "Active",
"wktGeometry": "SRID=27200;POINT (2310306.0879597953 5605922.516155325)",
"eventCreated": "2012-06-14T12:17:55.127+12:00",
"eventModified": "2012-08-15T17:46:26.197+12:00",
"informationSource": "NMC",
"supplier": "Official"
},

关于php - JSON解码未显示所有数据PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20343875/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com