X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=pctb%2Fdatabase-info-fetch;h=3b8db77c4209b05f9537b34f29e744a354d1b855;hp=b7ebe4159292c98456ba73239b3a3d2ff2026f17;hb=d7f05a5ba3fc396f2a350421163c9105b889c145;hpb=a433b27839ebdaa936803341a285e4ecc6a09105 diff --git a/pctb/database-info-fetch b/pctb/database-info-fetch index b7ebe41..3b8db77 100755 --- a/pctb/database-info-fetch +++ b/pctb/database-info-fetch @@ -68,13 +68,24 @@ sub ptcl ($) { p("{$_[0]}"); } +sub json_convert_shim ($) { + my ($json) = @_; + # 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 from_json($json); + } else { + return jsonToObj($json); + } +} + sub get_arches_islands () { my $ocean= $ENV{'YPPSC_OCEAN'}; die unless $ocean; my $url= "$pctb/islands.php?oceanName=".uc $ocean; my $resp= $ua->get($url); die $resp->status_line unless $resp->is_success; $jsonresp= $resp->content; - my $jobj= jsonToObj($resp->content); + my $jobj= json_convert_shim($resp->content); my $arches= [ jparsetable($jobj, 'arches') ]; my $islands= [ jparsetable($jobj, 'islands') ]; return ($arches,$islands);