decoding JSON issue in Perl code: , or ] expected while parsing array, at character offset -
i have written perl code working until recently, when tried run again. problem seems originate json::xs "decode_json" method.
code snippet:
use warnings; use strict; use moosex::singleton; use array::utils qw(:all); use data::dumper; use json::xs qw(encode_json decode_json); use storable; use tie::ixhash; open (my $observations_fh, '<', 'observations.json') or die "could not open observations.json\n"; $observations_json = <$obserations_fh>; @decoded_observations = @{decode_json($observations_json)};
usually, after code able go through each json component in loop , take specific information, error:
, or ] expected while parsing array, @ character offset 5144816 (before "(end of string)")
i saw similar question here, didn't resolve problem.
i have similar json decoding going on doesn't utilize @{decode_json($variable)}, when tried observations.json file, same error output.
i tried using json module, same error occurred.
any insight appreciated!
-cookersjs
that indicates have incomplete json in $observations_json
. assumption entire file consists of 1 line incorrect. use
my $observations; { open (my $observations_fh, '<', 'observations.json') or die("can't open observations.json: $!\n"); local $/; $observations_json = <$obserations_fh>; $observations = decode_json($observations_json); }
if doesn't help, observations.json
doesn't contain valid json.
Comments
Post a Comment