Re: [Json] Allow any JSON value at the top level

Tatu Saloranta <tsaloranta@gmail.com> Mon, 10 June 2013 23:49 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 6AD3821F99DB for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 16:49:07 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.435
X-Spam-Level:
X-Spam-Status: No, score=-2.435 tagged_above=-999 required=5 tests=[AWL=0.164, 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 Rv5RMtMJVqnO for <json@ietfa.amsl.com>; Mon, 10 Jun 2013 16:49:06 -0700 (PDT)
Received: from mail-we0-x22c.google.com (mail-we0-x22c.google.com [IPv6:2a00:1450:400c:c03::22c]) by ietfa.amsl.com (Postfix) with ESMTP id 6326421F99D6 for <json@ietf.org>; Mon, 10 Jun 2013 16:49:06 -0700 (PDT)
Received: by mail-we0-f172.google.com with SMTP id q56so5334256wes.17 for <json@ietf.org>; Mon, 10 Jun 2013 16:49:05 -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=8RPXJP4VhsU3qp7OYmpktBkunJ/cBpKl3Iefy6x6jUs=; b=0nX+4pCh6iuTxlyoD9l8B/0UQacLEJ6HqvdP8r51jX/PKcHWD45KMYWNYOKXMKPR51 6EAlyJcWdZx6pIqzAItqSnmyrlN4iSFo/uTFXXWBK8+xlzGn6UmscuToOMc38TlCjW6f nwKUhg0RiXpb4Pvkt+54MEiMgDf2hGOpaABGfb+kEPvTotvqDcXDMS83wEyhpaH3FYQo BBGx57fUD9XsqY1GacT8PJAM9xQeBdV6vYb7Obs4SfR4QCJ29b9e28BNGk466pnTWcEx GlTHe6wbbmfmSpYVZXP/skm7bp9fLuiqDXP1P7LAmaZHFODJhVXp8VPsGvMycsAIcMOC VZBw==
MIME-Version: 1.0
X-Received: by 10.194.179.129 with SMTP id dg1mr2674681wjc.38.1370908145333; Mon, 10 Jun 2013 16:49:05 -0700 (PDT)
Received: by 10.227.72.74 with HTTP; Mon, 10 Jun 2013 16:49:05 -0700 (PDT)
In-Reply-To: <3CE20E15-8F9E-4727-BBE7-FBB06F7CAC24@jorgechamorro.com>
References: <A723FC6ECC552A4D8C8249D9E07425A70FC33B5B@xmb-rcd-x10.cisco.com> <51b23e6d.6196420a.0b15.4245SMTPIN_ADDED_BROKEN@mx.google.com> <CAChr6SwrveU=fesF8VidDYWzeYMu2c1+=38+__BqHArxTiW5mg@mail.gmail.com> <51b4dbbe.64da440a.1fc2.6dd2SMTPIN_ADDED_BROKEN@mx.google.com> <CAChr6Sx_obmG+=sY100ySBLmevN0VJ_0Z9TjYGxcXKOx+UtnJA@mail.gmail.com> <51b4ec44.ea05420a.7c73.ffffa487SMTPIN_ADDED_BROKEN@mx.google.com> <CAChr6SxiZ2Yz6SiozQZpuYoGKSzWnUux6PukyWDkcvKsVyyRbQ@mail.gmail.com> <51b507b1.c686e00a.3a7e.ffffa0adSMTPIN_ADDED_BROKEN@mx.google.com> <CAO1wJ5R2H27qh-DWG5B8CzutkTFWxn-h+Qi1jiet23axxmvLyA@mail.gmail.com> <20130610201746.GC1057@mercury.ccil.org> <CAO1wJ5Q9mhspheU3h4NRx9x5LOz9yOgJBXhwPWBOVw-w71ncTQ@mail.gmail.com> <3CE20E15-8F9E-4727-BBE7-FBB06F7CAC24@jorgechamorro.com>
Date: Mon, 10 Jun 2013 16:49:05 -0700
Message-ID: <CAGrxA24T8m9oHmuVE8n+YG6ATr3sTTByet7Te8VyAmypD11p6w@mail.gmail.com>
From: Tatu Saloranta <tsaloranta@gmail.com>
To: Jorge <jorge@jorgechamorro.com>
Content-Type: multipart/alternative; boundary="089e013d194e05bce504ded56d2f"
Cc: John Cowan <cowan@mercury.ccil.org>, Jacob Davies <jacob@well.com>, Markus Lanthaler <markus.lanthaler@gmx.net>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Allow any JSON value at the top level
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 23:49:07 -0000

On Mon, Jun 10, 2013 at 3:53 PM, Jorge <jorge@jorgechamorro.com> wrote:

> It seems to me that top-level JSON values are a problem *only* for
> *streaming* parsers.
>
> A streaming parser can't tell whether the stream 333 was 3 separate threes
> or three-hundred-thirty-three, or even part of an incomplete 333445, or
> (chop it as you like).
>
> Parsing a stream with the other data types (strings, null, booleans): e.g.
> say, this stream: "string"truenullfalse"anotherstring"null"string"true"etc.
> etc." doesn't seem to be so much a problem (unless it gets out of sync!).
>
> But non-streaming parsers (such as the ones in EcmaScript 5) haven't any
> of these problems because they expect to receive a complete JSON payload
> containing a single JSON value (structured or not) and that's easy to parse
> unambiguously.
>

FWIW, streaming parsers I have been involved with expect separating
white-space and have no problem telling these cases apart; although it does
require a lookup to detect a white-space or end-of-stream.
Although there is no support from specification (since non-structured root
values are not specified as acceptable), this seems intuitive from user
perspective based on feedback I have gotten on this. This despite there
being theoretical problems (like: should commas be allowed or required, for
"implicit array" approach).

But what John C pointed out -- truncation of '333' from full '333445' -- is
actually an interesting and valid potential issue.

-+ Tatu +-