Re: [Json] JSON "Number" interoperability issues

Anders Rundgren <anders.rundgren.net@gmail.com> Sat, 21 April 2018 16:35 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 0FC39129C53 for <json@ietfa.amsl.com>; Sat, 21 Apr 2018 09:35:44 -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_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 rStLulaPiX1l for <json@ietfa.amsl.com>; Sat, 21 Apr 2018 09:35:41 -0700 (PDT)
Received: from mail-wr0-x22c.google.com (mail-wr0-x22c.google.com [IPv6:2a00:1450:400c:c0c::22c]) (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 3452A124F57 for <json@ietf.org>; Sat, 21 Apr 2018 09:35:41 -0700 (PDT)
Received: by mail-wr0-x22c.google.com with SMTP id p18-v6so11137893wrm.1 for <json@ietf.org>; Sat, 21 Apr 2018 09:35:41 -0700 (PDT)
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=T6nhICLlVCrPB/nqqgdpkOMMaDZC+pPH18Ms06rbWgQ=; b=Kv9wil1A/Q9ClwhpZ45CernsrA8s8Joukc7eJsFroIuudRqasTEk6pw88zQHHa5NAi Y6xoDzqqBHk1ZkNbeeEsLbcMMD+kFHPZzQytHa2anP6ZbdGD2SzddswsKsmWjT545jzL airzJE+qh19GXlN/QwYLAxd6+udOMmEtLrflhaSucQDAXuWpZIfaJexZDMvgXU4faZpi 4TO1B6iC0FdTfGDqyk3ErIRO9G7PHQEK5YrYI7H9ACx0QtYpTSedvp22aDzeg4IBPOzK GACklcrbXMDoo15/XThVSCKE7SzhKf26yOxZbQ52p5b8Y3CUiQI6BmcVPFGfN53fAk3P fQiA==
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=T6nhICLlVCrPB/nqqgdpkOMMaDZC+pPH18Ms06rbWgQ=; b=ocLchjTFPMiO9QtCe8LZH3RzIPBhkg6Hz2jrFPA9VapICgc0bnuGrBPqrR7T7IXudv GhtxlgziWH9VNnTe6gjbUFy59S4WtOYlLzzfD3ca9g/Xpfwq/WIE0QGNZFLwPmypkXKu Wwg5Etnch4fSf6MRjoRNGRCuenXo1BTwXUd/dhbwDhDTRvtReA7aMYDxYEmkEqmkWaTc Yz4tRw/7KXXaNlkn6yZ6GjAqI8h/WFtsGSzO4XchynoH1zKWT0dScxSTdKgS3Mmx/AaL T4u9Ro3G87eaPLfIg2GCRGhxCKFpIzhjR/p8areLg6br7HhrdETpkgt2YHUbI8p7JWJC oYRw==
X-Gm-Message-State: ALQs6tDY/mtoBRiUAA2US/dxJ2/KnLUJkbOSqfqK76qehkzkc6Zx8q2k JGCe/LijVb5iSamPSD2qRpdM6g==
X-Google-Smtp-Source: AIpwx493Ta0PCfCvYjJmHDRfcTNxPfIUh360c/TOFVvhR6xaGy5DzpPKPPBBxigV0W/lJVEsO96EcA==
X-Received: by 10.167.208.210 with SMTP id u18mr4676401edo.97.1524328539270; Sat, 21 Apr 2018 09:35:39 -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 x18sm4879822edi.58.2018.04.21.09.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Apr 2018 09:35:38 -0700 (PDT)
To: Henry Andrews <henry@cloudflare.com>
Cc: "json@ietf.org" <json@ietf.org>
References: <0326c065-543c-bc78-8c18-d0d9c1d6e0c1@gmail.com> <CANp5f1Of1efA2M3jfxy2arSYyb99b_x14NDFc+88oOXnZbha0w@mail.gmail.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <e9728a5c-4827-622e-9411-35affa7b91f9@gmail.com>
Date: Sat, 21 Apr 2018 18:35:22 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0
MIME-Version: 1.0
In-Reply-To: <CANp5f1Of1efA2M3jfxy2arSYyb99b_x14NDFc+88oOXnZbha0w@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/MTE-mPBDhonRKVyxPeE22RZIJdo>
Subject: Re: [Json] JSON "Number" interoperability issues
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: Sat, 21 Apr 2018 16:35:44 -0000

Dear Henry,

As seen by the .NET example I'm pointing to a rather generic problem.
I don't know who "owns" it.

json@ietf.org may be an appropriate venue for discussing how this could/should be addressed.

Ideally that should also involve people designing declarative schemes based on "decorating" data objects like in .NET.

For the monetary (decimal) data type there are already some standards out there that on their own seem have come to the same conclusion including the W3C: https://www.w3.org/TR/payment-request/#paymentcurrencyamount-dictionary

Thanx,
Anders

On 2018-04-21 18:14, Henry Andrews wrote:
> The JSON Schema project says no such thing.  JSON Schema says that if you want to define a sort of number that is *allowed by the JSON specification* but not interoperable by whatever definition of "interoperable" for whatever reason, then that is an ambiguity inherited from JSON and we will not exclude it from JSON Schema.
> 
> We do, however, provide many tools for constraining JSON numbers or numbers-as-strings within an interoperable subset.  I have been asking (including in conversations on issues you filed) for someone to contribute PRs on numeric / numbers-as-strings formats, but neither you nor anoyone else has stepped up.  Here is an example where I last asked for contributions in September 2017: https://github.com/json-schema-org/json-schema-spec/issues/361
> 
> I am aware that you are unhappy with our response to your issue, but please do not blame JSON Schema for JSON's ambiguities, or for other people happening to use ambiguous values while they also happen to use JSON Schema.  We help people describe how they want to use JSON.  We don't force them to use it in a particular way.  If want to avoid such values, it is entirely possible to write a JSON Schema to filter them out, and would be more possible if anyone understanding the concerns here were willing to submit a PR to define better values for "format".
> 
> thanks,
> -henry
> 
> 
> 
> 
> On Sat, Apr 21, 2018 at 8:14 AM, Anders Rundgren <anders.rundgren.net@gmail.com <mailto:anders.rundgren.net@gmail.com>> wrote:
> 
>     One might believe that JSON is a done deal but if you scratch a bit on the surface it seems that this is not the case.
> 
>     The root of the problem is that JSON offers a very limited set of data types, poorly matching applications.
>     The most problematic data type is the Number type which currently is {ab}used in various ways.
> 
>     The Open API/JSON Scheme folks claim that Number should be used for everything that smells like a number including BigInteger, while Microsoft in their .NET implementation serializes a BigInteger as: "myBigInteger":{"_bits":[1156841472,1164153218],"_sign":1}.  Other implementations use everything from Base64-encoding to simply putting such numbers within quotes.
> 
>     The same issue is valid for the monetary (decimal) data type which in payment-related standards like Open Banking in the UK and the W3C PaymentRequest is expressed as a JSON String "nnnnn.nnn", but in Open API/JSON Schema as a JSON Number.
> 
>     That is, for anything beyond what you can do natively in JavaScript, JSON offers close to ZERO interoperability.
> 
>     I-JSON [https://tools.ietf.org/html/rfc7493 <https://tools.ietf.org/html/rfc7493>] was a good start but it seems that there is more to do or is the general feeling that it is better to slowly deprecate JSON in favor of CBOR [https://tools.ietf.org/html/rfc7049 <https://tools.ietf.org/html/rfc7049>] and/or Protocol Buffers [https://developers.google.com/protocol-buffers/ <https://developers.google.com/protocol-buffers/>] ?
> 
>     Personally, I don't see any fundamental issue using JSON since you can map any data type to the String type.  This is way more flexible than defining hordes of discrete data types (aka "Fixing JSON"). Mapping can be performed programmatically like obj.getBigInteger("myBigInteger") or through declarative schemes. However, without defined mapping schemes you don't get that far.
> 
>     WDYT?
> 
>     //anders
> 
> 
>     _______________________________________________
>     json mailing list
>     json@ietf.org <mailto:json@ietf.org>
>     https://www.ietf.org/mailman/listinfo/json <https://www.ietf.org/mailman/listinfo/json>
> 
> 
> 
> 
> -- 
> 
>   *
>     |
> 
>     *Henry Andrews*  |  Systems Engineer
>     henry@cloudflare.com <mailto:henry@cloudflare.com>
> 
>     <https://www.cloudflare.com/>
> 
>     1 888 99 FLARE  | www.cloudflare.com <https://www.cloudflare.com/>
> 
>     |
> *
>