Re: [Json] Leading and trailing whitespace

Paul Hoffman <> Tue, 11 June 2013 02:02 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 2879221E809B for <>; Mon, 10 Jun 2013 19:02:12 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -102.432
X-Spam-Status: No, score=-102.432 tagged_above=-999 required=5 tests=[AWL=0.167, BAYES_00=-2.599, USER_IN_WHITELIST=-100]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id r-+nhds9bPCl for <>; Mon, 10 Jun 2013 19:02:10 -0700 (PDT)
Received: from (IPv6.Hoffman.Proper.COM [IPv6:2605:8e00:100:41::81]) by (Postfix) with ESMTP id B0CAF21E8099 for <>; Mon, 10 Jun 2013 19:02:09 -0700 (PDT)
Received: from [] ( []) (authenticated bits=0) by (8.14.5/8.14.5) with ESMTP id r5B21f1x061237 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Mon, 10 Jun 2013 19:01:42 -0700 (MST) (envelope-from
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\))
From: Paul Hoffman <>
In-Reply-To: <06e901ce6638$e8f27a90$bad76fb0$>
Date: Mon, 10 Jun 2013 19:01:41 -0700
Content-Transfer-Encoding: quoted-printable
Message-Id: <>
References: <06c101ce6625$0f891bf0$2e9b53d0$> <> <06e901ce6638$e8f27a90$bad76fb0$>
To: Jim Schaad <>
X-Mailer: Apple Mail (2.1508)
Subject: Re: [Json] Leading and trailing whitespace
X-Mailman-Version: 2.1.12
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 Jun 2013 02:02:15 -0000

On Jun 10, 2013, at 5:16 PM, Jim Schaad <> wrote:

> My intention here has nothing to do with canonicalization and everything to
> do with what constitutes a valid string from a parsing perspective.
> Consider for example the case of a text file which consists of a JSON text
> string with a trailing CRLF in the file.  If trailing whitespace is allowed
> then the entire text file is a legal JSON text string.  If the trailing
> whitespace is not allowed then it is not a legal JSON text string.  I am
> just trying to clarify which is true.

The "JSON text string" (called a "string" in RFC 4627) starts and ends with a quotation mark:
      string = quotation-mark *char quotation-mark
There is no "ws" anywhere there, but there sure are quotation marks.

> This makes a difference with the argument about moving all of the values to
> the top level since then the string (ignore the quotes) "   true \r\n"
> cannot be matched if you just want to say it is a Boolean literal (i.e. the
> non-terminator true).  Instead you need to say that it can have whitespace
> on either side of it.

The current grammar does not allow whitespace around "true" for that boolean value.

> I will agree that the original intention probably is just a question of
> academic interest.  The real question I should have asked would be are
> people taking advantage of the fact.
> That is the question of what about normal whitespace.

I would be interested if anyone sees anything in the document that disagrees with the above.

> I think there is a question about parsers that would accept the string
> {"a":"b"}A
> As I believe there are some that will (stop when you get to the end of the
> object) and some that will not.

If that is meant to be a JSON text, I cannot imagine how that is valid, but maybe I'm not creative enough.

--Paul Hoffman