diff options
author | Norbert Preining <preining@logic.at> | 2017-10-13 03:23:48 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2017-10-13 03:23:48 +0000 |
commit | bea24bc71979f672b3580e56cefc931ebf964906 (patch) | |
tree | 9fa0c62046e7c4d0c7daf3b07a440d8a40672118 /Master/tlpkg | |
parent | dedef3ec4c57627762b8203d36c6469e4a5c4a95 (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')
-rw-r--r-- | Master/tlpkg/TeXLive/TLPOBJ.pm | 16 |
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; } |