texlive[45531] Master/tlpkg/TeXLive/TLPOBJ.pm: improve json output:

commits+preining at tug.org commits+preining at tug.org
Fri Oct 13 05:23:49 CEST 2017


Revision: 45531
          http://tug.org/svn/texlive?view=revision&revision=45531
Author:   preining
Date:     2017-10-13 05:23:48 +0200 (Fri, 13 Oct 2017)
Log Message:
-----------
improve json output: numbers and booleans

Modified Paths:
--------------
    trunk/Master/tlpkg/TeXLive/TLPOBJ.pm

Modified: trunk/Master/tlpkg/TeXLive/TLPOBJ.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLPOBJ.pm	2017-10-13 01:41:42 UTC (rev 45530)
+++ trunk/Master/tlpkg/TeXLive/TLPOBJ.pm	2017-10-13 03:23:48 UTC (rev 45531)
@@ -425,6 +425,22 @@
   require JSON;
   #my $json = JSON::PP->new->utf8;
   my %foo = %{$self};
+  # make sure numbers are encoded as numbers
+  for my $k (qw/revision runsize docsize srcsize containersize
+                srccontainersize doccontainersize runcontainersize/) {
+    $foo{$k} += 0 if exists($foo{$k});
+  }
+  for my $k (keys %{$foo{'binsize'}}) {
+    $foo{'binsize'}{$k} += 0;
+  }
+  # encode boolean as boolean flags
+  if (exists($foo{'relocated'})) {
+    if ($foo{'relocated'}) {
+      $foo{'relocated'} = $JSON::true;
+    } else {
+      $foo{'relocated'} = $JSON::false;
+    }
+  }
   my $utf8_encoded_json_text = JSON::encode_json(\%foo); #  $json->encode(\%foo);
   return $utf8_encoded_json_text;
 }



More information about the tex-live-commits mailing list