chiark / gitweb /
Cope if very few commodities on screen. Use ADJUST_BOX much more.
[ypp-sc-tools.db-live.git] / pctb / database-info-fetch
index b7ebe4159292c98456ba73239b3a3d2ff2026f17..3b8db77c4209b05f9537b34f29e744a354d1b855 100755 (executable)
@@ -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);