[Json] JSON serialization - Two (incompatible) modes are in use

Anders Rundgren <anders.rundgren.net@gmail.com> Sat, 12 March 2016 17:28 UTC

Return-Path: <anders.rundgren.net@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 2450312D5D6 for <json@ietfa.amsl.com>; Sat, 12 Mar 2016 09:28:38 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.7
X-Spam-Level:
X-Spam-Status: No, score=-2.7 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9ZWWqOuo4jTQ for <json@ietfa.amsl.com>; Sat, 12 Mar 2016 09:28:36 -0800 (PST)
Received: from mail-wm0-x22a.google.com (mail-wm0-x22a.google.com [IPv6:2a00:1450:400c:c09::22a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 3D6BA12D5CF for <json@ietf.org>; Sat, 12 Mar 2016 09:28:36 -0800 (PST)
Received: by mail-wm0-x22a.google.com with SMTP id l68so56698900wml.0 for <json@ietf.org>; Sat, 12 Mar 2016 09:28:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=+yPN0EU4DWg9JJ4Zf/qjZLCPryJ8xW+h86RSF0h5opU=; b=yuXE3R7SMwhp6jFVIQNuKObCPpd3yvtd7rzzUwwSLlpk7zjanmHAZtZvkvAJzTncIN mpEyMWxy2vb4LUCwGcRB82QNxJXuOIM6Q5khEffp2cAs0UEzR6+GNK1BRp2WszVFOscy WbjcD1pWY/k0aEjT3+e+2JeYjwJtUcUXiIr2CbT4JtKARktE2FGb8qQgRvIFWeInOu6R jaT9Gt7ud4OpbyNIVE5BC2DnI8DFP7PJMgF1/8jGcZtqXoA7GUbFNdL9dBwvuY3tXiim xKEPSxmUxf6a5evTD5iFcS+57heiK4bh9zbhrGmX7rCMw4W/zAeSozMUt/lyEWSruEyd 5vBA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=+yPN0EU4DWg9JJ4Zf/qjZLCPryJ8xW+h86RSF0h5opU=; b=iag/6Ux9PmDEWtR/z5NK7UxqqB3a9f+v3F0iiaXmY8165JDDw0Ux4Pa92vCf0u2T0+ BdkJXS6qrc2kRDHM6JDxv20lXG02M7r2fJvi3upCBadWR+x938ibmJcA2ZpUU0bRLXrh BlfI4Rob4UHT4tt9SGwFJv4sp38gYRFm8oO4S6puQQQCNapaNSdV7eXrWEJw/CLvWn4m o4+UUuoP74xHRRNU7kfYgMIsI83d+RmMZALrJZlrDw5fqgh/Se2Sl4Ls94esX6AVZ203 hFCRye22d/8zRFpSnacIVlt7+yfXdwkgQYypNv8vhlFLIWwAWq4gY+RVMUM0lTM7mn1l EzvQ==
X-Gm-Message-State: AD7BkJIQTeb9DzherMa0ODXgGTFmkrP8bgfxXaNW7Z620963MATIUuo4NsWh9trZ/ZS6lw==
X-Received: by 10.28.111.135 with SMTP id c7mr9644185wmi.46.1457803714659; Sat, 12 Mar 2016 09:28:34 -0800 (PST)
Received: from [192.168.1.79] (83.203.130.77.rev.sfr.net. [77.130.203.83]) by smtp.googlemail.com with ESMTPSA id u16sm7919136wmd.5.2016.03.12.09.28.33 for <json@ietf.org> (version=TLSv1/SSLv3 cipher=OTHER); Sat, 12 Mar 2016 09:28:33 -0800 (PST)
To: "json@ietf.org" <json@ietf.org>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <56E4519D.2050109@gmail.com>
Date: Sat, 12 Mar 2016 18:27:57 +0100
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/HlxlFH277OKTKnRw9_3BGFdN07g>
Subject: [Json] JSON serialization - Two (incompatible) modes are in use
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
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: <https://mailarchive.ietf.org/arch/browse/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: Sat, 12 Mar 2016 17:28:38 -0000

Having looked around a bit it seems that the JSON world is rather divided and needs to consider supporting two different serializations, one which is ES6-compatible and another which is ES6-compatible but properly escaped to be used in browser as a JavaScript object. The latter means that '<', '>', and '&' must be expressed as \unnnn. Preferably quotes around identifier-compatible property names are also dropped in the JavaScript mode.

Currently, different JSON authors haven't really made up their mind and that makes interoperability for "Crypto Safe" JSON unnecessary difficult although RegEx can be used to get things right.

JSON.stringify does NOT have to change because  on the wire and for normalization purposes only the "true" JSON notation is useful.

Anders