Re: [Json] JSON Schema Language is nearly done: int53

Anders Rundgren <anders.rundgren.net@gmail.com> Wed, 31 July 2019 07:14 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 3DB4A12008F for <json@ietfa.amsl.com>; Wed, 31 Jul 2019 00:14:29 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 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_NONE=-0.0001, SPF_HELO_NONE=0.001, 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 8ujVJKMJ-ziE for <json@ietfa.amsl.com>; Wed, 31 Jul 2019 00:14:27 -0700 (PDT)
Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 A2A9A120088 for <json@ietf.org>; Wed, 31 Jul 2019 00:14:26 -0700 (PDT)
Received: by mail-wr1-x430.google.com with SMTP id n9so43336379wrr.4 for <json@ietf.org>; Wed, 31 Jul 2019 00:14:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=VAH/R1/0nymgvQGjVGldIu+EKc1Z6zgFGH3ggm6MWXs=; b=Hk+uj90D+iwHDBh70Cxp4NOIfUO8F6eRYkVIbRql1qZMSTVd1cpQimgXHFCbBfsvMe RUcLeSUe4XmwWpjiDdHcS7BH/SZSStoAeLFhmn8JfuNdvNkgMAaOSPXaotYKBTa+Q/EQ jWWepfFQ0k1PYJxIoG/bmnylpeCIu3rc9NrxNlYbc2cs0v/tTqY6Qg3Dy56wHLonlGDg v3eD7W1HGeRhSldRqYmZKCYP/cUJmKWFdtQQ+7pBpX5y7FTC/0gEOGq+ySbsq/UDkb5C zJQA0mDKPxn/ExFKnDbVKz3kMMF5YUs4q7VThLGlawJtC4dkjrGvVbMAfidpgJCltbcI QvFQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VAH/R1/0nymgvQGjVGldIu+EKc1Z6zgFGH3ggm6MWXs=; b=qCgD33UtldQchG1hFvaLZ/HS71s+1xk5C0OXhYNMOowFMwgMwucF+LHUu7CYNjWf+L Z+CmQAzlR+6bBpDroBRfOX2+3mD43+vzWqHI8+TkxpT+EMKD0LFJ6DKX5uCtU9fHqqL6 mY4X9ehoZa21aL97F8bWj0fTiSKiZhgO2sLQt4QDPOYcmTzkgCWa0ssvwOoMuxEVUsJf hNzFLVFmdrx09BS+ae8tc6rHhqozb3+ySZANFD01DcPNM7lttgfm6jSIORmgmKviPvWC WJXWvNJd5+/SUGDB/WbdmhmT9HRn+YuzR2fvp3TPpQKv8fV3wpkL3IZZZv7gzOwyKfXl Ga9w==
X-Gm-Message-State: APjAAAXLMU0gKDeyr4ii6rfkR9dv8TRpcnUS2Uw1ZhdqGbUtjQFUsvi+ G3cEL2kVuRMfv/lSVT2uFdu8dthf
X-Google-Smtp-Source: APXvYqyivpjULIoZDMQtv0najDKxJsgTkc9PLrTzFjBDN6oxuu1xB3AermHLvVU9qWBy/5zTak9U0A==
X-Received: by 2002:a5d:4941:: with SMTP id r1mr127273589wrs.225.1564557264597; Wed, 31 Jul 2019 00:14:24 -0700 (PDT)
Received: from [192.168.1.79] (25.131.146.77.rev.sfr.net. [77.146.131.25]) by smtp.googlemail.com with ESMTPSA id o20sm170612961wrh.8.2019.07.31.00.14.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Jul 2019 00:14:23 -0700 (PDT)
To: "Manger, James" <James.H.Manger@team.telstra.com>, JSON WG <json@ietf.org>
References: <SY2PR01MB27642C6983E387C397B11581E5DD0@SY2PR01MB2764.ausprd01.prod.outlook.com> <CAJK=1RjhuCYJe4-BSB++8+-dHG3LV8TdqsnFEPAoAkfJ1mOE3A@mail.gmail.com> <SY2PR01MB2764AD4523625006B1F3DFEBE5DC0@SY2PR01MB2764.ausprd01.prod.outlook.com> <aeb4dfcc-4227-2d8e-d1dc-914d078450fe@gmail.com> <SY2PR01MB2764600E16BA7A19025964EFE5DF0@SY2PR01MB2764.ausprd01.prod.outlook.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <7f663d84-eb38-271f-12c3-a0f4a2261090@gmail.com>
Date: Wed, 31 Jul 2019 09:14:22 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <SY2PR01MB2764600E16BA7A19025964EFE5DF0@SY2PR01MB2764.ausprd01.prod.outlook.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/SGgc3GB5O4xU2VXknEmH1ZapRY4>
Subject: Re: [Json] JSON Schema Language is nearly done: int53
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.29
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, 31 Jul 2019 07:14:29 -0000

On 2019-07-31 08:56, Manger, James wrote:
>> Dropping int64 is hardly an option, neither is BigInteger.   int53 is a special that for example fits UNIX "epoch".
> 
> Dropping int64 or BigInteger from *programming languages* is not an option. But dropping the ability for a JSON schema to suggest that arbitrary values of those types should be serialized to JSON numbers would be sensible.
> 
>> Arbitrarily sized integers are used by tons of applications based on JSON messaging and is available for most platforms including JS.
> 
> Sure, but they are not serialized to a JSON number. They are serialized to a JSON string of some form (eg "65537.00" or "AQAB").

This is where we (as a community of users) have a problem.  Jackson (now adopted by MSFT) indeed serializes BigInteger as JSON Number.  Other parties like Oracle have taken another (presumable unique) approach by using JSON number for int53-compliant BigIntegers and string notation for BigIntegers that doesn't fits int53.  I believe Oracle are considering a redesign though.

The following lines in Chrome shows this division in clear:

var big = 5n;
JSON.stringify(big)

 > VM887:1 Uncaught TypeError: Do not know how to serialize a BigInt
     at Object.stringify (<anonymous>)
     at <anonymous>:1:6

Anders

> 
>> That there are multiple ways of formatting integers in JSON is unfortunately a reality all JSON tool maker must (in some way) address.
> 
> Are you referring to 123, 123.0, 12.3E+1 and 1.23e2 as the multiple ways? Or 123, "123", "123.00", and "ew==" as the multiple ways?
> 
>> I would reverse the integer syntax and claim that integers SHOULD conform to standard integer (not JSON) syntax since a standard should not break the multitude of JSON tools that already implement this.
> 
> It sounds like you want JSON serializers to never use the fraction or exponent notations when a schema says a field is an integer. That's adding a distinction that doesn't exist in JSON so it will break things. A tool parsing JSON *without knowing the schema* may well use a double for a number, which it may then serialize in exponent notation even if it is an integer. For instance, in Java Double.toString(123000000) returns "1.23E8".
> Mind you, I suspect 1.23E8 will break many implementations that expect an integer so perhaps we should require the no-fraction-no-exponent form.
> 
> This is a separate issue to this thread, however, which was whether a JSON schema should offer "int53" as a type, and if it should offer "{u}int{8|16|32}" as types.
> 
> --
> James Manger
>