我的perl代码:
#!/usr/bin/perl
if ( not -f "$ARGV[0]" ) { die "$!"; }
open(DATA,"$ARGV[0]") || die "$!";
$data = <DATA>;
close(DATA);
use JSON qw(decode_json);
$tidy = decode_json($data);
use Data::Dumper;
$Data::Dumper::Terse = 1;
#$Data::Dumper::Indent = 1;
$Data::Dumper::Sortkeys = 1;
print Dumper $tidy;
我的 JSON 数据:
[{"n":"v8_skillgames","i":"m1QhFLZ2CI","s":21254,"t":1522783462114739392,"m":false},{"n":"v8_breakaway","i":"kpOIPLacEa","s":6163,"t":1522783462115880128,"m":false}]
意外输出:
[
{
'i' => 'm1QhFLZ2CI',
'm' => bless( do{\(my $o = 0)}, 'JSON::PP::Boolean' ),
'n' => 'v8_skillgames',
's' => 21254,
't' => '1522783462114739392'
},
{
'i' => 'kpOIPLacEa',
'm' => $VAR1->[0]{'m'},
'n' => 'v8_breakaway',
's' => 6163,
't' => '1522783462115880128'
}
]
我编写了一些 perl 脚本来解析单行 JSON 数据。但我得到了关于“m”的意外输出。怎么了?