Re: [Json] JSON Concluded? Well, maybe not

Anders Rundgren <anders.rundgren.net@gmail.com> Wed, 03 January 2018 07:06 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 BAFDA120713 for <json@ietfa.amsl.com>; Tue, 2 Jan 2018 23:06:42 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.699
X-Spam-Level:
X-Spam-Status: No, score=-2.699 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, URIBL_BLOCKED=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 M7OPAQqXvCFy for <json@ietfa.amsl.com>; Tue, 2 Jan 2018 23:06:40 -0800 (PST)
Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (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 78F8C120227 for <json@ietf.org>; Tue, 2 Jan 2018 23:06:40 -0800 (PST)
Received: by mail-wm0-x22f.google.com with SMTP id t8so935008wmc.3 for <json@ietf.org>; Tue, 02 Jan 2018 23:06:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=H6lV2au4HhBiveawoScqDKMuAvZVzkBQCnrLvWXg1IA=; b=ZlSj5//Sp5ZkjRHVSKW/Q81/bhH6JJ9yWkYKUQu5DtGdBrMnDH+BGigOvhzVBrY55t 6PKDsbWB3jQSt1W6rhHgvY476bCOW00exUXCbEdWLKVLl0RuHWilDEF09LDyURG3wcTj LQh+DIA+x17rGmRW7lB0Ty1pWuWVXEpV1YaaAazXKZifH6WsqiKCan89f5YGw3XiWq6Z WxuCjShcRV4tEzqRrzyEiXpNfT7Xo51BuOCHSycj5o7tgq9NerYFAHwx6pU7jgk1Ny8l ztPI3ZqAfVdoMtpH7CuALaJI8+gY+Q9CzJutLEfAet76J/5HaYLD8ZEcIun1RRKY0lVR m8sw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=H6lV2au4HhBiveawoScqDKMuAvZVzkBQCnrLvWXg1IA=; b=moFw/iEb95F2yqr0vgN63BgsF4GaTLNrzMbdCV9lnlnHEi5nu8I2Gyy3vJBsGi/AY/ tCmWT12tuArLxrQJmHg/p0QQCEhpgZCZBIaDzDfB5PoiBPaoH3p6DgELdXtLgRqPbtUo Xd8c3b22zlpaRa7wPnzy4wB0OCBBGBXDa7ZjKnBlVzKTQySFoTR5hJj2EsHzbNjkud4r 32W1wCq3C2+Peruh6HTMEEQtVEyAhniFc/fbDErQn6rDXerEQTkmJMAm2EkOftC5DxAp Nz3+zWRPmCIsyUKTq9C/D4qb3pV1AAaP9LGFPqwWTe6bcWjPLKr3jInRf3sMu38Q7I+/ OApw==
X-Gm-Message-State: AKGB3mJtwMF4sS6ewnWdcrVO+QWDy2inkE7y0fi9mGMRc/nwKZpzvqqt PVFTR+/53eyo2q6k0bRzIwqCTg==
X-Google-Smtp-Source: ACJfBouSSjjVS90n94P8K+WAdmeIPxYW0Ld8WidGRxanrB+kmm2E2kTy/+mw78EvZ+/mZitncPdT+w==
X-Received: by 10.80.211.18 with SMTP id g18mr1309156edh.279.1514963198872; Tue, 02 Jan 2018 23:06:38 -0800 (PST)
Received: from [192.168.1.79] (25.131.146.77.rev.sfr.net. [77.146.131.25]) by smtp.googlemail.com with ESMTPSA id g20sm315860edb.75.2018.01.02.23.06.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jan 2018 23:06:37 -0800 (PST)
From: Anders Rundgren <anders.rundgren.net@gmail.com>
To: Richard Gibson <richard.gibson@gmail.com>
Cc: JSON WG <json@ietf.org>
References: <13860352-ef8e-1d4b-2eff-27e275c25e3a@gmail.com> <CALH+fvqBGu0i=LcciYgOLSwbQJXfqgcXTdd=rxvfHfqiRyBj7g@mail.gmail.com> <CAHBU6itC+XAKhc_m_ywG5O2bpky9DnmzfiNVqP3WrxLaE7uenA@mail.gmail.com> <92077f95-5dd6-3f5b-4765-d14067f698ac@dret.net> <CADEL5zshRaHtVNAtNggwHaPKP9xWeePcBZcQc1EM8SEfUu41Uw@mail.gmail.com> <CALH+fvqkBkQCiXfx1cxXaX092sbW6fgUmUizXP1f=ScMZ3bBqQ@mail.gmail.com> <cb1ce20d-67f0-f4f4-8077-57c3d3f232b7@gmail.com> <CALH+fvqpaT0b8AfPigk93Fy5hhWFthiFJSfaMmkttpMgqiMvQw@mail.gmail.com>
Message-ID: <15337fea-5cec-0306-939b-df40b3a367d6@gmail.com>
Date: Wed, 03 Jan 2018 08:06:36 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2
MIME-Version: 1.0
In-Reply-To: <CALH+fvqpaT0b8AfPigk93Fy5hhWFthiFJSfaMmkttpMgqiMvQw@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/n4H9imgwffvqpZ5uWfucBzV7tD4>
Subject: Re: [Json] JSON Concluded? Well, maybe not
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.22
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: Wed, 03 Jan 2018 07:06:43 -0000

On 2018-01-02 17:33, Richard Gibson wrote:

<snip>

> JSON.stringify assumes information that is explicitly not conveyed 
> by JSON (in which an object is "an unordered collection of zero or 
> more name/value pairs") [1], and both its number serialization [2]
> and string serialization [3] specify aspects that harm compatibility
> (the former having arbitrary value-dependent branches, the latter being
> capable of producing invalid UTF-8 octet sequences that represent unpaired
> surrogate code points—unacceptable for exchange outside of a closed
> ecosystem [4]). JSON is a general language-agnostic interchange format,
> and ECMAScript JSON.stringify is *not* a JSON canonicalization solution.
> 
> [1]: https://tools.ietf.org/html/rfc8259#section-1
> [2]: http://ecma-international.org/ecma-262/7.0/#sec-tostring-applied-to-the-number-type
> [3]: http://ecma-international.org/ecma-262/7.0/#sec-quotejsonstring
> [4]: https://tools.ietf.org/html/rfc8259#section-8.1

JSON is a format defined the IETF and ECMA in some kind of cooperation.

ECMA's ECMAScript defines a set of ("fairly" easy to implement) JSON processing rules which are fully compatible [1] with the JSON format.

The idea using ES6+ number normalization was originally proposed by an esteemed member of the now concluded JOSE WG:
https://www.ietf.org/mail-archive/web/jose/current/msg05323.html

Following that path, I (accidentally) discovered the "missing link", ES6+'s preservation [2] of the original property ordering which in my mind is quite logical [3] for "ordinary" JSON usage as well.

A Java based reference implementation has been successfully tested against Chrome, Node.js, Firefox and Safari.

Feel free taking a test ride on: https://mobilepki.org/jose-jcs/home
Note that it outlaws signing a JSON "Number" expressed as "1.0" since the correct (according to ES6+) representation is "1".

Anders

1] possibly with the exception of "unpaired surrogate code points" which I admittedly know zilch about
2] with properties named as integers as a for practical purposes insignificant exception
3] Making data come out in the order it was specified addresses human aspects like debugging and documentation of JSON data