Failed to encode 2017-9-21T08-49-17.XML to JSON for indexing - malformed or illegal unicode character in string [�ndby IF], cannot convert to JSON at xx.pm line 1827.
####
Brøndby IF
##
##
use Cpanel::JSON::XS;
use XML::Fast;
sub esIndexFile2 {
my ($self, $file) = @_;
my $xml = do {
local $/ = undef;
open (my $fh, "<:encoding(ISO-8859-1)", $file) or die "Failed to open $file - $!";
<$fh>;
};
$xml =~ s/^(?:.*\n)//; # remove first line - the encoding line
my $hash;
eval {
$hash = xml2hash $xml;
};
if (my $ev = $@) {
warn("Failed to parse file $file for indexing - $@ - SKIPPING");
return;
}
my $json = eval {
encode_json($hash); # <------------ fails here
};
if (my $ev = $@) {
$self->logwarn("Failed to encode $file to JSON for indexing - $@ - SKIPPING");
return;
}
return 1;
}