Re: [Json] Leading and trailing whitespace

Tatu Saloranta <tsaloranta@gmail.com> Tue, 11 June 2013 17:29 UTC

Return-Path: <tsaloranta@gmail.com>
X-Original-To: json@ietfa.amsl.com
Delivered-To: json@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id A2E2E21F856D for <json@ietfa.amsl.com>; Tue, 11 Jun 2013 10:29:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.447
X-Spam-Level:
X-Spam-Status: No, score=-2.447 tagged_above=-999 required=5 tests=[AWL=0.152, BAYES_00=-2.599, HTML_MESSAGE=0.001, NO_RELAYS=-0.001]
Received: from mail.ietf.org ([12.22.58.30]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D89wEkPsnlOU for <json@ietfa.amsl.com>; Tue, 11 Jun 2013 10:29:09 -0700 (PDT)
Received: from mail-wg0-x22c.google.com (mail-wg0-x22c.google.com [IPv6:2a00:1450:400c:c00::22c]) by ietfa.amsl.com (Postfix) with ESMTP id 4A6B121F88FB for <json@ietf.org>; Tue, 11 Jun 2013 10:29:09 -0700 (PDT)
Received: by mail-wg0-f44.google.com with SMTP id m15so5077491wgh.23 for <json@ietf.org>; Tue, 11 Jun 2013 10:29:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/pNu8dYwljLG59bK7XDWUfAbH3ya3xHHLM0K7KHrS8c=; b=ljz73L9QZAnhhON44fWo2bmiD/Pu34+vgmQA4dyEsYN41QIdGEkARohT14ZtvNApow m3kNSDvjbFVLfigSpVNjPNmLcq0vSTrD8BlPKn0DM1VRIAuc8N41zyFhTrAIrJ0fLJmx R72GVC49ZdX37R+VmEUmUueGBG4hpMdSs6rFW9mTFWUm4JZRZAnumRc8yD8fCtHbiMd/ qc9I1Cf2NwW9sK+dmPYG+Zzj8LcLNoD/lTm00tjDsc5OypVEUO0DYzVSKVOkzU+qQ94H B7238pLric9ljimh5SfUhdeB9i1nFxQox+YKkM7zcAz5camCl1qcehw4IlG+0Om/+y4n wwAw==
MIME-Version: 1.0
X-Received: by 10.194.90.244 with SMTP id bz20mr9625132wjb.69.1370971748438; Tue, 11 Jun 2013 10:29:08 -0700 (PDT)
Received: by 10.227.72.74 with HTTP; Tue, 11 Jun 2013 10:29:08 -0700 (PDT)
In-Reply-To: <CAK3OfOiBmzCdQtyUFoBkSFMFJijE7K8eR+9YUv7bhD2YaQBW2Q@mail.gmail.com>
References: <06c101ce6625$0f891bf0$2e9b53d0$@augustcellars.com> <379266A1-82C1-4FF5-BD7C-EE657F1FD41F@vpnc.org> <06e901ce6638$e8f27a90$bad76fb0$@augustcellars.com> <51DE7E41-D682-4340-A234-7F7CFE513C10@vpnc.org> <070b01ce664b$e5e0ac10$b1a20430$@augustcellars.com> <6E03D281-D6BA-424D-A30A-3DA18E61A051@vpnc.org> <CAK3OfOiBmzCdQtyUFoBkSFMFJijE7K8eR+9YUv7bhD2YaQBW2Q@mail.gmail.com>
Date: Tue, 11 Jun 2013 10:29:08 -0700
Message-ID: <CAGrxA25o6shGp4tko8PT5hf3gOJfjpqKVHiSxDx-vaO1_wiAoQ@mail.gmail.com>
From: Tatu Saloranta <tsaloranta@gmail.com>
To: Nico Williams <nico@cryptonector.com>
Content-Type: multipart/alternative; boundary="047d7bfd090a10187904dee43c67"
Cc: Jim Schaad <ietf@augustcellars.com>, Paul Hoffman <paul.hoffman@vpnc.org>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Leading and trailing whitespace
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.12
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: Tue, 11 Jun 2013 17:29:10 -0000

On Mon, Jun 10, 2013 at 8:42 PM, Nico Williams <nico@cryptonector.com>wrote:

> On Mon, Jun 10, 2013 at 9:53 PM, Paul Hoffman <paul.hoffman@vpnc.org>
> wrote:
> > On Jun 10, 2013, at 7:32 PM, "Jim Schaad" <ietf@augustcellars.com>
> wrote:
> >
> > You might be asking "if we allow other JSON items at the top level, will
> we also allow optional whitespace before and after". But that's a
> supposition, not a question about what is in the document now.
>
> Sure, but since we're full-out having the any value type at the
> top-level discussion (and it looks like we'll at least have to have
> informational text acknowledging that ECMAScript will allow them) this
> becomes relevant.
>
> Do implementations that allow any value type at the top-level allow
> leading and/or trailing whitespace?
>
>
Yes. I was surprised to even see the question -- since white space is
allowed between array and object entries, it would seem surprising if
whitespace at root context behaved differently.
At least I have never encountered a case where parser discarded piece of
JSON due to root-level whitespace (I mostly work on java)

The most practical reason is really that when humans edit JSON, trailing
space after root object or array may be added by text editor. White spce is
all about readability.



> *Should* they?
>
> IMO the intuitive answer to the last should be "yes", that arbitrary
> amounts of whitespace can surround any value regardless of where it
> appears.  But my intuition could be wrong.
>

I think it should be allowed unless there are actual clear reasons not to
allow it.
And unlike with XML limitation for no whitespace before XML declaration,
there does not seem to be solid reasons, other than perhaps suggestion that
since this was omitted from definition it should not be added.

-+ Tatu +-