JSON解码未显示所有数据PHP


JSON Decode not showing all data PHP

我正在尝试用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中的任何问题。

即使在将我的JSONhttp://jsonlint.com/我只得到最后一段。有人知道我做错了什么吗?

感谢

您的json有问题。您正在重复属性"道路事件"。我假设它们都不应该包含在数组[内的同一对象{中。

{
"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"
    },
  1. 只需将,"roadevent":替换为,
  2. JSON结束Gisborne Region"}]}"
  3. JSON启动{"data":{"roadvevent":[{"alternativeRoute"