Subject: | Double-encoding and decoding |
This module currently double-encodes all output and double-decodes all input by default. The standard (and now RFC-required) practice with JSON is that it should always be encoded to UTF-8, so the most efficient/correct way to do this would be:
sub read_json
{
my $json = read_binary(@_);
return decode_json($json);
}
sub write_json
{
my ($filename, $ref) = @_;
my $json = encode_json($ref);
return write_binary($filename, $json);
}
However, this removes the feature of allowing encoding to be specified. Any implementation that allows encoding to be specified will be slower. Do we need this option?