summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLPOBJ.pm
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2017-10-13 03:23:48 +0000
committerNorbert Preining <preining@logic.at>2017-10-13 03:23:48 +0000
commitbea24bc71979f672b3580e56cefc931ebf964906 (patch)
tree9fa0c62046e7c4d0c7daf3b07a440d8a40672118 /Master/tlpkg/TeXLive/TLPOBJ.pm
parentdedef3ec4c57627762b8203d36c6469e4a5c4a95 (diff)
improve json output: numbers and booleans
git-svn-id: svn://tug.org/texlive/trunk@45531 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLPOBJ.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLPOBJ.pm16
1 files changed, 16 insertions, 0 deletions
diff --git a/Master/tlpkg/TeXLive/TLPOBJ.pm b/Master/tlpkg/TeXLive/TLPOBJ.pm
index 9e91daa25ad..77f2290e442 100644
--- a/Master/tlpkg/TeXLive/TLPOBJ.pm
+++ b/Master/tlpkg/TeXLive/TLPOBJ.pm
@@ -425,6 +425,22 @@ sub as_json {
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;
}