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

Jorge <jorge@jorgechamorro.com> Sun, 09 June 2013 21:39 UTC

Return-Path: <jorge@jorgechamorro.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 AADE721F8EF7 for <json@ietfa.amsl.com>; Sun, 9 Jun 2013 14:39:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599]
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 U8UGFkzVyxJD for <json@ietfa.amsl.com>; Sun, 9 Jun 2013 14:39:25 -0700 (PDT)
Received: from mail-we0-x22a.google.com (mail-we0-x22a.google.com [IPv6:2a00:1450:400c:c03::22a]) by ietfa.amsl.com (Postfix) with ESMTP id A4A0121F8EBE for <json@ietf.org>; Sun, 9 Jun 2013 14:39:24 -0700 (PDT)
Received: by mail-we0-f170.google.com with SMTP id w57so4401313wes.1 for <json@ietf.org>; Sun, 09 Jun 2013 14:39:23 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=/3+Xx5EdfJ1YXaITsMwS+UkliA1e6R2k4yL8qKYZAFE=; b=ZoxGYs1zAa+idP/GhGeMB4j6+f6OOPfx+xiqhDhdjqLHPQOjn5eHc5ywDknUo0y2jd AD7z545lA5SfjKojSrRzFWl05qGHMuszIR4JnQJfbphXFnJnHK2YnDftYVAApmrDtUT7 XqpsxfRQJXy0r//MVoqJymV0ooQIcc2WCcXcR1MiGjA8/bSDpXuOC5v5R2zTxYGUY5Je C+eqkfSiNXph5TnJMLKYFzuCD1TJF24jbeTEOGp5ptqTOv3sWNR8x69UQW1ooXriW5mO 4ZBsoNLfMd1B4ZjEz5iLx1K6+ExyFZTdJlRWHtwjF07VFrOpSGfTBHaG6uE1aJPqEJAC Hqrw==
X-Received: by 10.180.23.101 with SMTP id l5mr728235wif.30.1370813963445; Sun, 09 Jun 2013 14:39:23 -0700 (PDT)
Received: from [192.168.10.50] (99.Red-79-144-66.dynamicIP.rima-tde.net. [79.144.66.99]) by mx.google.com with ESMTPSA id h8sm8029767wiz.9.2013.06.09.14.39.22 for <multiple recipients> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 09 Jun 2013 14:39:23 -0700 (PDT)
Mime-Version: 1.0 (Apple Message framework v1085)
Content-Type: text/plain; charset="us-ascii"
From: Jorge <jorge@jorgechamorro.com>
In-Reply-To: <CAK3OfOjU+9Mbgocq0hxrCsk7VshTw06DekyUR3nN_PHmCNLj-w@mail.gmail.com>
Date: Sun, 09 Jun 2013 23:39:19 +0200
Content-Transfer-Encoding: quoted-printable
Message-Id: <8C697BA1-AD6B-4E8A-B5AF-0F4ACADEA2C6@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.c5a22a0a.1b34.ffffa62dSMTPIN_ADDED_BROKEN@mx.google.com> <CAK3OfOjU+9Mbgocq0hxrCsk7VshTw06DekyUR3nN_PHmCNLj-w@mail.gmail.com>
To: Nico Williams <nico@cryptonector.com>
X-Mailer: Apple Mail (2.1085)
X-Gm-Message-State: ALoCoQlM5tpwKyfe2dSCuvYvQzbKy1q3DgOlY8bMPouQSrvTaullMHAjYj+iLfUNjugDtJoepR/i
Cc: Markus Lanthaler <markus.lanthaler@gmx.net>, 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: Sun, 09 Jun 2013 21:39:25 -0000

On 09/06/2013, at 23:08, Nico Williams wrote:

> At least several encoders and parsers allow any value type at the top-level, either as an option or no matter what.

All the current browsers can both .parse() and .stringify() strings, numbers, null and booleans at the top-level, per the ES5 specs (*):

JSON.parse(JSON.stringify("string"))
"string"
JSON.parse(JSON.stringify(27))
27
JSON.parse(JSON.stringify(true))
true
JSON.parse(JSON.stringify(false))
false
JSON.parse(JSON.stringify(null))
null
JSON.parse(JSON.stringify([27]))
[27]
JSON.parse(JSON.stringify({a:1}))
{a:1}

(*) <http://ecma-international.org/ecma-262/5.1/#sec-15.12.1.2>

<http://ecma-international.org/ecma-262/5.1/#sec-15.12.2>
"The parse function parses a JSON text (a JSON-formatted String) and produces an ECMAScript value. The JSON format is a restricted form of ECMAScript literal. JSON objects are realized as ECMAScript objects. JSON arrays are realized as ECMAScript arrays. JSON strings, numbers, booleans, and null are realized as ECMAScript Strings, Numbers, Booleans, and null."

<http://ecma-international.org/ecma-262/5.1/#sec-15.12.3>
"The stringify function returns a String in JSON format representing an ECMAScript value. It can take three parameters. The first parameter is required. The value parameter is an ECMAScript value, which is usually an object or array, although it can also be a String, Boolean, Number or null."
-- 
( Jorge )();