[Json] Leading and trailing whitespace

"Jim Schaad" <ietf@augustcellars.com> Mon, 10 June 2013 21:55 UTC

Return-Path: <ietf@augustcellars.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 C72D021F9AB9 for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 14:55:20 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.599
X-Spam-Level:
X-Spam-Status: No, score=-3.599 tagged_above=-999 required=5 tests=[AWL=0.000, BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1]
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 lpgBGUWhs-0I for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 14:55:15 -0700 (PDT)
Received: from smtp1.pacifier.net (smtp1.pacifier.net [64.255.237.171]) by ietfa.amsl.com (Postfix) with ESMTP id 4342E21F9AA3 for <json@ietf.org>; Mon, 10 Jun 2013 14:55:11 -0700 (PDT)
Received: from Philemon (mail.augustcellars.com [50.34.17.238]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jimsch@nwlink.com) by smtp1.pacifier.net (Postfix) with ESMTPSA id D732B2CA1F for <json@ietf.org>; Mon, 10 Jun 2013 14:55:10 -0700 (PDT)
From: "Jim Schaad" <ietf@augustcellars.com>
To: <json@ietf.org>
Date: Mon, 10 Jun 2013 14:54:19 -0700
Message-ID: <06c101ce6625$0f891bf0$2e9b53d0$@augustcellars.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Outlook 14.0
Thread-Index: Ac5mIupHFvoeUrtwQTulCaqwQck6sA==
Content-Language: en-us
Subject: [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: Mon, 10 Jun 2013 21:55:20 -0000

The current specification allows for arbitrary whitespace to occur before
and after an array or object.  I would like to know if this is what was
intended to begin with or not.

There are two different things that could be done about this (one of which
would potentially be necessary if you allowed all values in a JSON-text.


1.  Some of the ABNF could be cleaned up to eliminate situations where you
end up with two ws non-terminals in a row.  Thus the ABNF could be modified
from

   JSON-text = object / array

      begin-array     = ws %x5B ws  ; [ left square bracket

      begin-object    = ws %x7B ws  ; { left curly bracket

      end-array       = ws %x5D ws  ; ] right square bracket

      end-object      = ws %x7D ws  ; } right curly bracket

      name-separator  = ws %x3A ws  ; : colon

      value-separator = ws %x2C ws  ; , comma

      object = begin-object [ member *( value-separator member ) ]
               end-object

      member = string name-separator value

   array = begin-array [ value *( value-separator value ) ] end-array

to

JSON-text = object / array
begin-array = %x5B  ws ; [ left square bracket
begin-object = %x7B ws ; { left curly brace
end-array = ws %5D ; ] right square bracket
end-object = ws %7D ; } right curly brace
name-separator = ws %x3A ws ; : colon
value-separator = ws %x2C ws ; , comma

If needed then JSON-text would become either
JSON-text = ws value ws 
Or
JSON-text = ws object ws / ws array ws

2.  There is nothing in the current parser or generator text which says what
to do if you come across a string which either has leading/trailing white
space or a string which has a complete JSON-text string followed by
non-white space characters.   I would hope that the second case should cause
either an error or some other indicator that the entire string was not
consumed.  I am slightly agnostic about the first case but would kind of
like to eliminate leading and trailing whitespace.


Jim