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

Anders Rundgren <anders.rundgren.net@gmail.com> Mon, 01 January 2018 06:10 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 6789E12422F for <json@ietfa.amsl.com>; Sun, 31 Dec 2017 22:10:40 -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 HQkQb4tgCfZC for <json@ietfa.amsl.com>; Sun, 31 Dec 2017 22:10:38 -0800 (PST)
Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) (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 4BCC31205F0 for <json@ietf.org>; Sun, 31 Dec 2017 22:10:38 -0800 (PST)
Received: by mail-wm0-x22e.google.com with SMTP id n138so56527232wmg.2 for <json@ietf.org>; Sun, 31 Dec 2017 22:10:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=v3/OOfTcwyztDQj69NvTgt3m3c23nEpbuB8tUyQ/PZo=; b=TDmptWqwkGTeRh/7shOyQVhQtXO0xm2IszXIq+WccyW2sqwnttKErbIPjLhemJVNdT O+NLv0tI/wXiDeRSJ291pdnhPbP7K+OEJCOaSRSEKY2D0TGi3/qUhTxvsK6gFsP86gFU PUXrHC2NcGe3vTyhh/BlQxR8H8Zix8+FZl9D/uC96d/9j+F694qxDpd3PkWB6WnpjLbn 4rVHEePuxpkitS3alLMmFL8d8xgQ6HbXyXNf536vmDliWQ8NYwCGJKmNKj4ttV4Yj9WR wCQriZw75hRGh3uIfqrcFUYQhJO2TwWAqDs1zJdjMpJbiRIAE37T6nikTssPslNINqIO +flA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=v3/OOfTcwyztDQj69NvTgt3m3c23nEpbuB8tUyQ/PZo=; b=ibkGlb2zrAvTfkXt+u+MxtOiORncsWknfNI2KGrrxps035zBMF1sIKMsTccTnnUJjL h0vQOKDsqHPxSnGnNrNuZX5kEG5TCLky6gZYwJU8K+/khI90R0NnpDQLbQnWPt66CmGy 3CGTuS8bGcyoLYOKCww9d5iuE4/8o6G5BpbzJ9Mk0eNPjfmnKZWB9aJUYqiU+Fu4mlCW e0k8uC/EG8HRFpStjAgiwyNhbPnbshw+13u8L5znGOu7ZaE3V2RFYYcqG1F1oaXxutya BPhzsJo3TtdZ70z46HcMuGqNTXdqgxvy+S5kzLROI9QZgc32xDstxAGIqY6UpuneRMkz Th3A==
X-Gm-Message-State: AKGB3mLK9OnNegl1ACX5TyEodPIPPHDhST61C6tevhp2zf0odhzaXuaF kQv2v4cU6951xvYzIiWhx1s4Fg==
X-Google-Smtp-Source: ACJfBovjjj/Fs5/vkhYndrrr80UZX+PHWIdXijkBrVL8VAr6sw35y69b3TIZ92wffsAbE1DiMoPraQ==
X-Received: by 10.80.154.193 with SMTP id p59mr56038330edb.304.1514787036506; Sun, 31 Dec 2017 22:10:36 -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 n3sm35683059edb.46.2017.12.31.22.10.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Dec 2017 22:10:35 -0800 (PST)
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>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <cb1ce20d-67f0-f4f4-8077-57c3d3f232b7@gmail.com>
Date: Mon, 01 Jan 2018 07:10:32 +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+fvqkBkQCiXfx1cxXaX092sbW6fgUmUizXP1f=ScMZ3bBqQ@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/8mEyvwfqgCwkpApUDiiUGGaP-RM>
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: Mon, 01 Jan 2018 06:10:40 -0000

On 2018-01-01 00:39, Richard Gibson wrote:
> On Sun, Dec 31, 2017 at 4:34 PM, Anders Rundgren <anders.rundgren.net@gmail.com <mailto:anders.rundgren.net@gmail.com>> wrote:
> 
>     For normalization it turns out that JSON.parse() and JSON.stringify() as specified by ECMA and already supported by the most widely available JSON tools is all you need!
> 
> 
> That is definitely not true. A trivial counterexample: https://jsbin.com/luyoveyuqu/edit?js,console,output

Right, JSON.stringify() doesn't not canonicalize but preserve property order [1] + normalize data which for "crypto-safe" JSON applications is entirely sufficient.

If you go back to your example you can see another nicety of the EMCA parse/stringify scheme: JSON data is actually generated in the order specified by the programmer.

Or as I like to put it: JSON grew out of JavaScript, now it has come home again :-)

Cheers,
Anders

1] Extract from an I-D in preparation:

For JavaScript optimization reasons, ECMAScript's JSON.parse()
internally rearranges order of properties with names expressed
as integers, making a parsed JSON string like
'{"2":"First","A":"Next","1":"Last"}' actually serialize as
'{"1":"Last","2":"First","A":"Next"}'.  Due to this fact,
signature creators must (in the hopefully rather unusual case
cross platform applications would mandate numeric property names),
in an here unspecified way, "emulate" this scheme since this
behavior is not intended to be an additional requirement to
support by JSON tools in general in order to use this specification.