X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=blobdiff_plain;f=yarrg%2FCommodsWeb.pm;h=d423a299c48136c20d7fe9ab3c408cffba402ec7;hp=5f85511f5fed815f2d73e70e435c710a383e2daa;hb=ee80b1ab92305277d07d99faea8682aea690b59a;hpb=efc8497c2414dfded724d7181e11df53b947e387 diff --git a/yarrg/CommodsWeb.pm b/yarrg/CommodsWeb.pm index 5f85511..d423a29 100644 --- a/yarrg/CommodsWeb.pm +++ b/yarrg/CommodsWeb.pm @@ -52,7 +52,7 @@ BEGIN { $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = qw(&dbw_connect &ocean_list $sourcebasedir - &to_json &to_json_protecttags + &to_json_shim &to_json_protecttags &set_ctype_utf8); %EXPORT_TAGS = ( ); @@ -103,9 +103,20 @@ sub dbw_connect ($) { return dbr_connect($datadir, $ocean); } +sub to_json_shim ($) { + my ($obj) = @_; + # In JSON.pm 2.x, jsonToObj prints a warning to stderr which + # our callers don't like at all. + if ($JSON::VERSION >= 2.0) { + return to_json($obj); + } else { + return objToJson($obj); + } +} + sub to_json_protecttags ($) { my ($v) = @_; - my $j= to_json($v); + my $j= to_json_shim($v); $j =~ s,/,\\/,g; return $j; }