in reply to Re: how to acces data in JSON
in thread how to acces data in JSON
But an ERROR appears: Not an ARRAY reference at script.pl line 20. (line 20 is that one: for my $s (@$j) ) how could I solve it? thanks thanks thanks!!!use strict; use warnings; binmode STDOUT, ":utf8"; use utf8; use JSON; my $json; { local $/; open my $fh, "<", "struc_cover_edu.json"; $json = <$fh>; close $fh; } my $j = JSON->new->decode($json); for my $s (@$j) { next unless $s->{PROT_NAME} eq 'XPA'; for my $p (@{$s->{COVERTURA}}) { print $p->{PSTART},"\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to acces data in JSON
by hdb (Monsignor) on Apr 28, 2013 at 14:36 UTC |