summaryrefslogtreecommitdiff
path: root/lib/VNDB/Func.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/Func.pm')
-rw-r--r--lib/VNDB/Func.pm12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 3b315c93..ac9fdd58 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -204,16 +204,18 @@ sub fmtvote {
}
-my $JSON; # cache
+# JSON::XS::encode_json converts input to utf8, whereas the below functions
+# operate on wide character strings. Canonicalization is enabled to allow for
+# proper comparison of serialized objects.
+my $JSON = JSON::XS->new;
+$JSON->canonical(1);
-# JSON::XS::encode_json converts input to utf8, whereas these functions
-# operate on wide character strings.
sub jsonEncode ($) {
- ($JSON ||= JSON::XS->new)->encode(@_);
+ $JSON->encode(@_);
}
sub jsonDecode ($) {
- ($JSON ||= JSON::XS->new)->decode(@_);
+ $JSON->decode(@_);
}
# Insert JSON-encoded data as script, arguments: id, object