Could you please help me with this little script?
I am trying to pre-parse (i.e. check that I can get the data I need) a JSON file from the UK Charity Commision. The data source is not known for being well-formated but I am pretty sure the issue here is with my code and (lack of) understanding of character encoding!
use strict; use warnings; use Data::Dumper; use utf8; use JSON; $/ = undef; open my $fh, '<:encoding(UTF-8)', 'publicextract.charity.json' or die +$!; my $data = <$fh>; close $fh; $data =~ s/^\x{feff}//; # Strip off BOM my $json = decode_json $data; # <-- Wide character in subroutine ent +ry at json.pl line 15. foreach my $j(@$json) { print "$j->{'charity_contact_phone'},$j->{'charity_contact_email'} +\n"; } print "\nComplete!\n\n";
The documentation for decode_json says it takes a UTF8 encoded string. So I have saved the JSON file as UTF8 using TextPad and opened the file with the same encoding. But, decode_json is croaking Wide character in subroutine entry
What have I overlooked?
In reply to Wide characters and UTF8 by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |