Re: [Json] serializing sequences of JSON values

Nico Williams <> Tue, 11 March 2014 00:48 UTC

Return-Path: <>
Received: from localhost ( []) by (Postfix) with ESMTP id 904231A0672 for <>; Mon, 10 Mar 2014 17:48:43 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -1.044
X-Spam-Status: No, score=-1.044 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] autolearn=no
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id gMMaak3HzwlJ for <>; Mon, 10 Mar 2014 17:48:42 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 919291A0670 for <>; Mon, 10 Mar 2014 17:48:42 -0700 (PDT)
Received: from (localhost []) by (Postfix) with ESMTP id 39F9A1604 for <>; Mon, 10 Mar 2014 17:48:37 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed;; h= mime-version:in-reply-to:references:date:message-id:subject:from :to:cc:content-type;; bh=iEfmGvc0sb1a5enzSZCp uuQo4bY=; b=REv8qTwhAiA69h9ogVz2Viplx7PDvjs4xLc0fWoMxdllirkRWZ1v u9iaocuJwctbi99dwJxMZzgD5YhF8BJcOPgMXHD66X/STTpA9h+T7XHKS1n4blgh Jh+rDgmlO6aesf1GuuXjdzjsCeSOe/40i0NayXkvCFGRnMUZFtx18uQ=
Received: from ( []) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: by (Postfix) with ESMTPSA id D90271600 for <>; Mon, 10 Mar 2014 17:48:36 -0700 (PDT)
Received: by with SMTP id x48so9251701wes.7 for <>; Mon, 10 Mar 2014 17:48:35 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20130820; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=45Hq82RQUcCg2YzFRIr0zuis6C3NOLcjhDqwwLvhyvw=; b=gcm7EIcZJsZI5JZ6BY+gxAhtUWNkvPJGq27OY51bsXJqCacgWrmMvjHIw5apzpdlKs hOqe5sJUKWrOuhCgkCsLHTdh+yOnTV97Vl8c25URxG2hHDNKsxZ1RA/mtiZuHa+EbZH+ w8UaxYsn3UreYLfJO3E/7vALEHTmBWm1RWevqneKJNTVW/OHX3a3oPxwqsqtidEhQMey x/33l/d/riU8qKUq6S43SlBDRO56gniQQYQcxSS062XYDuE2dkYNxloWdIC734p3DNyE OMG+RENo1L8yOEkn9VSfRDyHo0ZqPDe7ZdPBe+IRHUst0FSEYfGB8H+HJ8G9kkaNBUKm LcHQ==
MIME-Version: 1.0
X-Received: by with SMTP id dy8mr645555wib.5.1394498915589; Mon, 10 Mar 2014 17:48:35 -0700 (PDT)
Received: by with HTTP; Mon, 10 Mar 2014 17:48:35 -0700 (PDT)
In-Reply-To: <>
References: <> <> <> <>
Date: Mon, 10 Mar 2014 19:48:35 -0500
Message-ID: <>
From: Nico Williams <>
To: Marc Lehmann <>
Content-Type: text/plain; charset=UTF-8
Cc: "" <>
Subject: Re: [Json] serializing sequences of JSON values
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 11 Mar 2014 00:48:43 -0000

On Mon, Mar 10, 2014 at 5:59 PM, Marc Lehmann <> wrote:
> As an implementer (with JSON::XS, which so precisely followed the spec
> that it found at least one bug in the official testsuite btw.), I am now
> in a fairly bad situation - silently switch to the new JSON format and
> push the problem to the users, or force them to enable the new version
> manually. JSON::XS did support the "new JSON" format via a switch as an
> extension, but applications had to explicitly ask for it, so presumably
> know what they are dealing with.

Hmm, no.  No one is forcing any parser or any JSON-using app to handle
non-array/object JSON text sequences if it didn't before.

The only problem I see is the need to disambiguate some cases (see
separate thread), which IMO is best done by always emitting a newline
after every JSON text.

Every parser I've worked with has an option to parse things other than
arrays/objects at the top-level, and every encoder I've ever seen has
an option for compact output (i.e., no newlines).  Given just that and
a convention of emitting a newline after every text then it's
trivially easy to build an application that unambiguously handles
sequences of JSON texts encoding any value type at the top-level.
(It's a bit trickier if the encoder has no option to emit "compact"
texts, since then one might need a parser that can consume inputs