変換する必要があり、以下のperlスクリプトは、JSONperlは
#!/usr/bin/perl
use strict;
use warnings;
use JSON;
my $file = 'players.json';
open(my $input, "<", $file) or die $!;
my $json_data = decode_json(
do { local $/; <$input> }
);
foreach my $player_id (keys %{$json_data}) {
foreach my $fixture (
@{ $json_data->{$player_id}->{fixture_history}->{all} })
{
print join(",",
$player_id, $json_data->{$player_id}->{web_name},
@{$fixture}, "\n",);
}
}
JSONファイルは、/ tmpフォルダの下にあるCSVするCSVファイルにJSONに変換します+/tmpに私が取得:
./jsonTOcsv.pl
Not a HASH reference at ./uri.pl line 15, <$input> line 1.
は、ここでは何が間違っているアドバイスをしてください?
基本的には、ハッシュ構造の配列のハッシュを期待していますが、そうではないようです。 – Ouki
ここで問題は何ですか? –
'Use Data :: Dumper; print Dumper($ json_data); ' – toolic