Re: [Json] JSON "Number" interoperability issues

Henry Andrews <henry@cloudflare.com> Sat, 21 April 2018 16:14 UTC

Return-Path: <henry@cloudflare.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 A1DC712D574 for <json@ietfa.amsl.com>; Sat, 21 Apr 2018 09:14:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.009
X-Spam-Level:
X-Spam-Status: No, score=-2.009 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_DKIMWL_WL_HIGH=-0.01, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cloudflare.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 KSc4hV-OMg1B for <json@ietfa.amsl.com>; Sat, 21 Apr 2018 09:14:42 -0700 (PDT)
Received: from mail-wr0-x22e.google.com (mail-wr0-x22e.google.com [IPv6:2a00:1450:400c:c0c::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 9B012124F57 for <json@ietf.org>; Sat, 21 Apr 2018 09:14:41 -0700 (PDT)
Received: by mail-wr0-x22e.google.com with SMTP id f14-v6so30237765wre.4 for <json@ietf.org>; Sat, 21 Apr 2018 09:14:41 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6DmytZ86f7FrGODs8dn/a0c2PfjA/juPYe7J8JqJa7o=; b=xw7fBxcEDrVT4InADF4cYqKDNKVy/6Srsh/NsRUzFu8cRFKes9VzYhfHr60mwje3W+ a65y4jPA4k8vg7McIX17anDu4DIf6DCNCq4gS3CRSCtpr0uohmx5wTwuxOIrTDNRBdVn MRCaQbS7XexWWGD6tSEIQ+bQOoWo2x9VRe9S8=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6DmytZ86f7FrGODs8dn/a0c2PfjA/juPYe7J8JqJa7o=; b=njHPXCDkk71tzgJrkOiOjraBrL3l5pRBG7VRfhZ1lSpexJqOay4IHtmcggacDw04zs T9D129Ljx3Xv9tV2q0cUdrl8cYFDoz1xJpd6mcuoFNRMO1XtKtUEXo/FDTAWuEDNApnO BEqfzfQlqYlpKdztK40kPl8hn60GznlkfkFkra7PLejmYOJlIpDlHq7GxWBr9DyP/oFN Q/y0uD7Acic67qaQHU31Pg8yVktd4zocOvsZKIFQDy7krChiTdgZNtbFSDuB3F1k5yct Namlj+qjW3g16n4nSrzg0ghvBADr270rzIAqb3WLlCNGP5MMxPslz+2n3nBdKY8q3sV5 bohw==
X-Gm-Message-State: ALQs6tCyasM9fZqj6iZcz8LyZBxYnzAk4QTIXqZX9tWaz4N6+D4z2VWc Hsa9ORIL+pKEv3eqvBE5L9jL5zuL5mObFZitxssJwQ==
X-Google-Smtp-Source: AIpwx4/8BER/ThQhp7snEWPuViJBudn7f4LBVDHbBkgYZ3SzhVf2zsWa6E1mW90VtNNVnfnTgIyQzoNwUUTayo/pF9Q=
X-Received: by 10.28.20.140 with SMTP id 134mr4373269wmu.87.1524327280007; Sat, 21 Apr 2018 09:14:40 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.28.198.79 with HTTP; Sat, 21 Apr 2018 09:14:19 -0700 (PDT)
In-Reply-To: <0326c065-543c-bc78-8c18-d0d9c1d6e0c1@gmail.com>
References: <0326c065-543c-bc78-8c18-d0d9c1d6e0c1@gmail.com>
From: Henry Andrews <henry@cloudflare.com>
Date: Sat, 21 Apr 2018 09:14:19 -0700
Message-ID: <CANp5f1Of1efA2M3jfxy2arSYyb99b_x14NDFc+88oOXnZbha0w@mail.gmail.com>
To: Anders Rundgren <anders.rundgren.net@gmail.com>
Cc: "json@ietf.org" <json@ietf.org>
Content-Type: multipart/alternative; boundary="001a1145b0720bf836056a5e1af4"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/RSilMDDXiIFGdAWXx0hBdkQjlNA>
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:14:45 -0000

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> 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] 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/r
> fc7049] and/or 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
> https://www.ietf.org/mailman/listinfo/json
>



-- 

   -

   *Henry Andrews*  |  Systems Engineer
   henry@cloudflare.com
   <https://www.cloudflare.com/>

   1 888 99 FLARE  |  www.cloudflare.com
   -