Re: [Json] Using a non-whitespace separator (Re: Working Group Last Call on draft-ietf-json-text-sequence)

Nico Williams <nico@cryptonector.com> Wed, 04 June 2014 22:40 UTC

Return-Path: <nico@cryptonector.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 8181F1A0373 for <json@ietfa.amsl.com>; Wed, 4 Jun 2014 15:40:07 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.444
X-Spam-Level:
X-Spam-Status: No, score=-0.444 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FM_FORGED_GMAIL=0.622, IP_NOT_FRIENDLY=0.334, J_CHICKENPOX_72=0.6, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f9YryLW9qTh6 for <json@ietfa.amsl.com>; Wed, 4 Jun 2014 15:40:05 -0700 (PDT)
Received: from homiemail-a55.g.dreamhost.com (sub4.mail.dreamhost.com [69.163.253.135]) by ietfa.amsl.com (Postfix) with ESMTP id 4F4621A0348 for <json@ietf.org>; Wed, 4 Jun 2014 15:40:05 -0700 (PDT)
Received: from homiemail-a55.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a55.g.dreamhost.com (Postfix) with ESMTP id C7920161E for <json@ietf.org>; Wed, 4 Jun 2014 15:39:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h= mime-version:in-reply-to:references:date:message-id:subject:from :to:cc:content-type:content-transfer-encoding; s= cryptonector.com; bh=6lqkC9BaUYpBmIZBj36ZwikMAhQ=; b=MAG3OdWq0ST rkD+1rxxTTHothMhIihyHHh0k9fLzu5MuRVEKJLtKsAiMhX1feaD2OGgtwdMzh1H hIhm7M6HQQkxK3pDaBA5Izz+CPzVSLRkK1jMPeDz2ydzT0KIhAVrmjZDJejhG46o iYxEjpveo/wqTbXZM69v3Nt0hIHuPkg8=
Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a55.g.dreamhost.com (Postfix) with ESMTPSA id 738BA161D for <json@ietf.org>; Wed, 4 Jun 2014 15:39:58 -0700 (PDT)
Received: by mail-wg0-f47.google.com with SMTP id x12so166701wgg.18 for <json@ietf.org>; Wed, 04 Jun 2014 15:39:56 -0700 (PDT)
MIME-Version: 1.0
X-Received: by 10.194.93.202 with SMTP id cw10mr9248323wjb.95.1401921596280; Wed, 04 Jun 2014 15:39:56 -0700 (PDT)
Received: by 10.216.29.200 with HTTP; Wed, 4 Jun 2014 15:39:56 -0700 (PDT)
In-Reply-To: <CAHBU6iu_Mrnd+yYpBcg9Yy7Xw4s9s-LCfk0f9_TJGXxz76c9wg@mail.gmail.com>
References: <CAK3OfOidgk13ShPzpF-cxBHeg34s99CHs=bpY1rW-yBwnpPC-g@mail.gmail.com> <CAHBU6itr=ogxP4uoj57goEUSOCpsRx1AXVnW1NQwSTPxbbttkw@mail.gmail.com> <CAK3OfOhft+XJeMrg5rdY9E6fxAkJ2qsT3UHwu7zt=NEz2Q3XOQ@mail.gmail.com> <CAK3OfOhy-N0zjCVxtOMB8SqZEKceVvBz9Y6i0fo2W8i+gHKm4Q@mail.gmail.com> <CAK3OfOiQnLq29cv+kas3B8it-+82VmXvL3Rq1C5_767FDhBjRg@mail.gmail.com> <03CFAB3E-F4C6-4AE8-A501-8525376C4AA7@vpnc.org> <CAK3OfOja-17V391tTK91R98X8XQzd0iPnur2=oo4ii+MCOt+Rg@mail.gmail.com> <CFB42410.4EDDC%jhildebr@cisco.com> <CAMm+Lwime-=UQPu3t2ty05CZLb7xUMi9KGi31Xi2B7RNF5S3Og@mail.gmail.com> <CAK3OfOg_k4Ngq+z1pn4b+XRf0M1Hqx8qZ9BtW0sa8QQ+bjKJyA@mail.gmail.com> <084664DB-A55D-465E-8888-97BA0BB59637@vpnc.org> <CAHBU6itEph5GzB-P8bUUvUMopRNxcCE-16qys7ofhdmsDvpN4w@mail.gmail.com> <CAMm+LwjoeC1R4O2iCPo+RfUFn4Qca4zyytqa817ayH60mNaWLg@mail.gmail.com> <CAK3OfOhjPZUXK6C0qSsQQZvOgR3Sv3SWpyH=qTuihuDC9uvXrA@mail.gmail.com> <CAHBU6iu_Mrnd+yYpBcg9Yy7Xw4s9s-LCfk0f9_TJGXxz76c9wg@mail.gmail.com>
Date: Wed, 04 Jun 2014 17:39:56 -0500
Message-ID: <CAK3OfOgcyQSo8DbWngNuAZFgA6JMPY-VTgRvzuy4UXz-g_QpCw@mail.gmail.com>
From: Nico Williams <nico@cryptonector.com>
To: Tim Bray <tbray@textuality.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: http://mailarchive.ietf.org/arch/msg/json/1trIacgfG5LNSByf4fVb--sktko
Cc: Phillip Hallam-Baker <ietf@hallambaker.com>, Paul Hoffman <paul.hoffman@vpnc.org>, Joe Hildebrand Hildebrand <jhildebr@cisco.com>, IETF JSON WG <json@ietf.org>
Subject: Re: [Json] Using a non-whitespace separator (Re: Working Group Last Call on draft-ietf-json-text-sequence)
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <json.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/json>, <mailto:json-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/json/>
List-Post: <mailto:json@ietf.org>
List-Help: <mailto:json-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/json>, <mailto:json-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 04 Jun 2014 22:40:08 -0000

On Wed, Jun 4, 2014 at 3:36 PM, Tim Bray <tbray@textuality.com> wrote:
> I totally don’t get why you want the LF involved.  I can’t see how it would
> make any difference, could you explain more?

Sure.

Short version:

I'm a fan of ASN.1 and PER and XDR.  But it's true that JSON is a
_textual_ encoding and so I can use $PAGER.  That's nice.  And if I'm
going to use $PAGER, then newlines between texts is... necessary.

Long version:

Let's start with this: jq(1) _today_ deals in JSON text sequences as
inputs and outputs.  You can ask jq(1) to output compact texts (like
pretty much all JSON encoders I know) or pretty-print, even colorize
texts, but jq(1) will always output a newline after every text, so
this:

% jq -C . some-file | $PAGER -R
<page through colorized pretty-printed JSON text(s) in some-file>

and the texts in 'some-file' will not run on: each will end in a newline.

Most JSON encoders I know have a "compact" output option: the whole
text with no extra whitespace.  jq(1)'s encoder does too, and so we
can:

% jq -c -f program.jq input-file > output
% wc -l output
<total number of output texts>

And sure, I could just as easily:

% jq length output
<total number of output texts>

and that's more correct even (since if 'output' came from some other
processor, there might be consecutive newlines, giving an incorrect
count with wc(1)).

But I can do all sorts of things with just text.  Like: use grep(1) as
an optimization to avoid parsing non-matching texts:

% grep -i "error.*some.error.or.other" output | jq -C -f
more-specific-filter.jq | $PAGER -R
<colorized pretty-printed texts>

Sure, it's an optimization, but don't diss optimizations.

PHB mentions $EDITOR.  I mention $PAGER.  And as I said, I'm a fan of
binary encodings.

If jq(1) spoke some binary encoding of JSON none of that would work,
but that's OK: if I had and were using such an encoding (that worked
well with sequences) I'd just not expect text-oriented tools to be any
use, or I could throw a re-encoder in the pipe so I could use
text-oriented tools.

Nico
--