Re: [Json] serializing sequences of JSON values

Nico Williams <nico@cryptonector.com> Fri, 14 March 2014 04:21 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 3DBE71A000A for <json@ietfa.amsl.com>; Thu, 13 Mar 2014 21:21:18 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 1.753
X-Spam-Level: *
X-Spam-Status: No, score=1.753 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FH_RELAY_NODNS=1.451, FM_FORGED_GMAIL=0.622, HELO_MISMATCH_COM=0.553, IP_NOT_FRIENDLY=0.334, RDNS_NONE=0.793] 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 Sw4bRM5BZBG4 for <json@ietfa.amsl.com>; Thu, 13 Mar 2014 21:21:17 -0700 (PDT)
Received: from homiemail-a72.g.dreamhost.com (unknown [69.163.253.176]) by ietfa.amsl.com (Postfix) with ESMTP id F2EB11A0002 for <json@ietf.org>; Thu, 13 Mar 2014 21:21:16 -0700 (PDT)
Received: from homiemail-a72.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a72.g.dreamhost.com (Postfix) with ESMTP id 508356B007C for <json@ietf.org>; Thu, 13 Mar 2014 21:21:10 -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; s=cryptonector.com; bh=m6nqJxliztsI9iI1T/t6 /bCcpik=; b=gWYQBPuC7sEtqVcO13judd+9wfLoALY5yPexdJYZAlzkXxfl3HWW HhNtkxYFoxWDU1/JqFH0uZbUQvrf/YV0jzIG5mH7m9gNXdFm1tNrOQSzfwIUWbrA gtWQiFsesd0d/5cSkJO34hzUC5ExHVJWVoF8yV4mcWitWnc1kfpdNOY=
Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by homiemail-a72.g.dreamhost.com (Postfix) with ESMTPSA id 02D8E6B007B for <json@ietf.org>; Thu, 13 Mar 2014 21:21:09 -0700 (PDT)
Received: by mail-wi0-f176.google.com with SMTP id hr14so4814184wib.15 for <json@ietf.org>; Thu, 13 Mar 2014 21:21:08 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=DNus/+yfHF40Xh9KT8Vpqn9fQd5Ve6d082/LTJ1ok5k=; b=L/UFc+SRK7UhJCnlig2uLitDhdifedgmuK1FEU0zwgEfcdJWrBVbh91TZoGUmhELVE 2DYEISWJcAIr9PE17ON1+MDIBvOl0VTwXxoRoXEhfttjFCXXETKbS3G/UukxHeUHuu3b TfwgDqnvATCuc8ual0zoesLiuOsfbhBxBYqc9WS6c/RGyDoFcs7KHNXC+naxkTAEouf3 R5PJiY05FKRB9LVXTVImSFvOPNkh8T+ZHh51rbwcf17xj3AaKqnfzfQUXcEeVGGQeDRW LiK6+UI334cGtVlgy1C50lS9/XePBXfZg6WYnsfabqY1dBw1AJjFRoMSI5lNA2HWt1aK BrVg==
MIME-Version: 1.0
X-Received: by 10.194.78.173 with SMTP id c13mr4741523wjx.0.1394770868873; Thu, 13 Mar 2014 21:21:08 -0700 (PDT)
Received: by 10.216.199.6 with HTTP; Thu, 13 Mar 2014 21:21:08 -0700 (PDT)
In-Reply-To: <CAGrxA26HRqa+R580qfEMXU_JGid-UDzwwmQigOkOW0OWuA9mpg@mail.gmail.com>
References: <em2c025504-6532-4513-a339-3d71c4cdfbda@helsinki> <5FC8412F-30E5-4F80-AB63-6715B1053098@vpnc.org> <58a4b20f768b484c94a850c4eba71ec5@BL2PR02MB307.namprd02.prod.outlook.com> <53222FFC.8070204@cisco.com> <5322714F.6080508@it.aoyama.ac.jp> <CAGrxA26HRqa+R580qfEMXU_JGid-UDzwwmQigOkOW0OWuA9mpg@mail.gmail.com>
Date: Thu, 13 Mar 2014 23:21:08 -0500
Message-ID: <CAK3OfOier6uQ4nVuuCP+uWV+eRbYh8qqAi4FVdWqNLHOh94L+A@mail.gmail.com>
From: Nico Williams <nico@cryptonector.com>
To: Tatu Saloranta <tsaloranta@gmail.com>
Content-Type: text/plain; charset=UTF-8
Archived-At: http://mailarchive.ietf.org/arch/msg/json/16X-XWzfpAUhcmRruQMNqtXHJwo
Cc: =?UTF-8?Q?Martin_J=2E_D=C3=BCrst?= <duerst@it.aoyama.ac.jp>, Matt Miller <mamille2@cisco.com>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] serializing sequences of JSON values
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: Fri, 14 Mar 2014 04:21:18 -0000

On Thu, Mar 13, 2014 at 11:04 PM, Tatu Saloranta <tsaloranta@gmail.com> wrote:
> Major challenge with sequence of XML documents is really just implementors,
> and inertia.
> Having written a fully conformat XML parser that optionally supports
> "fragment mode" (Woodstox for Java; implements SAX and Stax APIs) I can say
> that compared to all other work, supporting multiple root-level documents is
> a minor addition. Mode is used/useful for supporting XMPP, as well as for
> use for streaming logging, similar to what has been discussed for JSON. It
> has to be explicitly enabled (since such usage is non-compliant, having
> multiple roots).
>
> There are some minor details (like xml declaration, what to do if it is
> repeated) to deal with,
> to allow simple concatenation, but all in all it is not a big technical
> problem. I mean, compared to writing actual fully compliant parser
> (supporting DTD is 80+% of the deal).

By comparison, parsing a JSON text sequence can be done with any JSON
parser, especially when the encoder is nice enough to use "compact"
encoding options and uses newline as the separator.  To be efficient
it's best to have an incremental parser (that is, that can be fed
chunks of input until the end of the text is found).

That's how jq handles JSON text sequences.  It's really quite simple.

Nico
--