From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 905701F4B4; Tue, 5 Jan 2021 09:24:49 +0000 (UTC) Date: Tue, 5 Jan 2021 09:24:49 +0000 From: Eric Wong To: meta@public-inbox.org Subject: JSON pretty-printing [was: [4/4] ... (and maybe lei)] Message-ID: <20210105092449.GA22853@dcvr> References: <20210105090437.22801-1-e@80x24.org> <20210105090437.22801-5-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210105090437.22801-5-e@80x24.org> List-Id: Eric Wong wrote: > [ > { "name": "James Smythe", "email": "james@example.com" }, > { "name": null, "email": "jane@example.com" }, > { "name": "John Smith", "email": "john@example.com" } > ] I might make JSON the default "lei q" output to the terminal or pager when no mbox/Maildir/IMAP destination is specified. Unfortunately, attempting JSON pretty-printing seems to add excessive vertical white space and I can't easily match the formatting above. jq(1) can't seem to do what I want, either. With the Perl JSON modules, the array of 3 hash tables would either be all on one-line (not human friendly), or have excessive vertical space: [ { "email" : "james@example.com", "name" : "James Smythe" }, { "email" : "jane@example.com", "name" : null }, { "email" : "john@example.com", "name" : "John Smith" } ] So maybe I'll bypass some of the structural/indentation stuff and only rely on the JSON modules to properly quote strings. I'm already doing that when outputting search results (similar to "git log"), just on a per-smsg level to avoid building giant arrays with 1000K search results in memory all at once. JSON requiring keys (not just values) to be quoted also annoys me a bit as being extra visual noise.