From ce5b169e0b224fd9233736ef49eb9478d0b9f2cb Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 5 Jul 2009 19:28:54 +0100 Subject: [PATCH] Cope with JSON.pm version 2 which has an incompatible change --- pctb/database-info-fetch | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pctb/database-info-fetch b/pctb/database-info-fetch index b7ebe41..d3619ca 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) { + 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); -- 2.30.2