about summary refs log tree commit homepage
path: root/lib/PublicInbox/LeiInspect.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-10-02 08:16:21 +0000
committerEric Wong <e@80x24.org>2021-10-02 20:09:16 +0000
commit3826b39b6433ecec96a0230ae4602b7c819fde66 (patch)
tree3d3c4bc1b1cdf96de473c0689d13846a789cce9a /lib/PublicInbox/LeiInspect.pm
parent7b4071a3afb78f575dc16ecb710e16ef83485a6c (diff)
downloadpublic-inbox-3826b39b6433ecec96a0230ae4602b7c819fde66.tar.gz
These are always numeric, but none of the Perl code cares;
we want to prevent JSON from quoting them.
Diffstat (limited to 'lib/PublicInbox/LeiInspect.pm')
-rw-r--r--lib/PublicInbox/LeiInspect.pm10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/PublicInbox/LeiInspect.pm b/lib/PublicInbox/LeiInspect.pm
index 2158b996..f18e31c5 100644
--- a/lib/PublicInbox/LeiInspect.pm
+++ b/lib/PublicInbox/LeiInspect.pm
@@ -13,6 +13,12 @@ use PublicInbox::Config;
 use PublicInbox::MID qw(mids);
 use PublicInbox::NetReader qw(imap_uri nntp_uri);
 
+sub _json_prep ($) {
+        my ($smsg) = @_;
+        $smsg->{$_} += 0 for qw(bytes lines); # integerize
+        +{ %$smsg } # unbless and scalarize
+}
+
 sub inspect_blob ($$) {
         my ($lei, $oidhex) = @_;
         my $ent = {};
@@ -143,7 +149,7 @@ sub inspect_num ($$) {
         }
         if ($ibx && $ibx->over) {
                 my $smsg = $ibx->over->get_art($num);
-                $ent->{smsg} = { %$smsg } if $smsg;
+                $ent->{smsg} = _json_prep($smsg) if $smsg;
         }
         defined($docid) ? inspect_docid($lei, $docid, $ent) : $ent;
 }
@@ -164,7 +170,7 @@ sub inspect_mid ($$) {
         if ($ibx && $ibx->over) {
                 my ($id, $prev);
                 while (my $smsg = $ibx->over->next_by_mid($mid, \$id, \$prev)) {
-                        push @{$ent->{smsg}}, { %$smsg }
+                        push @{$ent->{smsg}}, _json_prep($smsg);
                 }
         }
         $ent;