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

Pete Cordell <petejson@codalogic.com> Fri, 02 August 2019 11:00 UTC

Return-Path: <petejson@codalogic.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 93D961200A3 for <json@ietfa.amsl.com>; Fri, 2 Aug 2019 04:00:49 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 3.099
X-Spam-Level: ***
X-Spam-Status: No, score=3.099 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, GB_SUMOF=5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001] autolearn=no autolearn_force=no
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 jexi2qtyq-xF for <json@ietfa.amsl.com>; Fri, 2 Aug 2019 04:00:47 -0700 (PDT)
Received: from ppsa-online.com (ppsa-online.com [217.199.162.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id F40731200B1 for <json@ietf.org>; Fri, 2 Aug 2019 04:00:46 -0700 (PDT)
Received: (qmail 5936 invoked from network); 2 Aug 2019 11:58:19 +0100
Received: from host109-149-217-70.range109-149.btcentralplus.com (HELO ?192.168.1.72?) (109.149.217.70) by lvps217-199-162-217.vps.webfusion.co.uk with ESMTPSA (AES128-SHA encrypted, authenticated); 2 Aug 2019 11:58:19 +0100
To: Ulysse Carion <ulysse@segment.com>, Anders Rundgren <anders.rundgren.net@gmail.com>
Cc: Carsten Bormann <cabo@tzi.org>, John Cowan <cowan@ccil.org>, "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> <7f663d84-eb38-271f-12c3-a0f4a2261090@gmail.com> <CAJK=1RjqqtZvdWBJNXR6ebKFT1KSkNJHQjiydQ7RJX6aPyB+9g@mail.gmail.com> <CAD2gp_QWcVVbnmuZfuqawR1fW7=iVgtuD1tKWVQ=ME3gjDORvQ@mail.gmail.com> <5ECB215B-AA05-47AB-AC8F-F14A74A46FEE@tzi.org> <df86cce7-f6f4-2077-6076-6d550368c6f6@gmail.com> <CAJK=1Rh3mtXxB2iz-HYZ1xzZ8BUqFs2FX8CnE+xxyr7733784A@mail.gmail.com>
From: Pete Cordell <petejson@codalogic.com>
Message-ID: <6c13347a-b64b-c43e-67be-e704450025e4@codalogic.com>
Date: Fri, 02 Aug 2019 12:00:43 +0100
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: <CAJK=1Rh3mtXxB2iz-HYZ1xzZ8BUqFs2FX8CnE+xxyr7733784A@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Language: en-GB
Content-Transfer-Encoding: 8bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/vk3ZeD6spKS6PQCNlXpJR_OMBl0>
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: Fri, 02 Aug 2019 11:00:50 -0000

On 02/08/2019 05:39, Ulysse Carion wrote:
> Within this discussion we've seen precisely why I don't think JSL should 
> take on directly supporting currency-related stuff. Anders describes the 
> W3C's payment-request spec, which uses a string, whereas Carsten 
> describes the multiply-by-denominator approach, which is the one that 
> Stripe uses: https://stripe.com/docs/api/charges/create
> 
> I think JSL is useful without currency-specific support, just as it is 
> useful without int64/uint64. Better to ship fewer things well, no?

A recent solution to JCR for managing an ever growing type system is to 
allow the base type to have a format URI designator with it. So JSL 
would end up looking something like:

"amount": {
    "type": "string",
    "format": 
"https://www.w3.org/TR/payment-request/#dfn-valid-decimal-monetary-value" }

The format can then be defined in separate documents.  Which layer of 
validation ensures the format is correct is an implementation detail. 
The lower layers could just ensure it's a string. Higher layers could 
ensure that the string has the correct format.


> On Thu, Aug 1, 2019 at 12:54 PM Anders Rundgren 
> <anders.rundgren.net@gmail.com <mailto:anders.rundgren.net@gmail.com>> 
> wrote:
> 
>     On 2019-08-01 21:07, Carsten Bormann wrote:
>      > On Aug 1, 2019, at 18:08, John Cowan <cowan@ccil.org
>     <mailto:cowan@ccil.org>> wrote:
>      >>
>      >> Monetary amounts need to be represented as JSON strings, or your
>     auditors will be down on you like a ton of bricks.
>      >
>      > That is only true if you naively equate the interchange data
>     model with your application data model.
>      >
>      > There is nothing wrong with interchanging currency values as
>     floating point values if you properly process them on ingestion. 
>     Typically, you multiply with a common denominator (such as 100 or
>     1000 [egyptian pounds?, or US mills as in gasoline prices]) and
>     round to the nearest integer.
> 
>     In this case there are standards that are interoperable with any
>     JSON parser although you typically have to perform one or two
>     additional operations in order to get the proper local representation:
>     https://www.w3.org/TR/payment-request/#dfn-valid-decimal-monetary-value
> 
>     We lucky guys(?) who build our own stuff have it natively:
>     https://cyberphone.github.io/doc/openkeystore/javaapi/org/webpki/json/JSONObjectReader.html#getMoney-java.lang.String-java.lang.Integer%2d
>     mapped => "string"
> 
>     Anders
> 
>      >
>      >> The sum of ten 0.1 values is 0.9999999999999999, not 1.0,
>     assuming the float64 interpretation that essentially all JSON
>     readers assign to JSON numbers.
>      >
>      > Right, you can’t *compute* with them as floating point values
>     (well, you can, but you need to be even more careful with the rounding).
>      >
>      > You still can *interchange* them as floating point values if you
>     have enough precision (binary32 notably doesn’t for most
>     applications; you really need binary64, and you are still limited to
>     applications that handle less than ~ 90 Microsofts or Apples a piece
>     and don’t need more internal decimal places at the same time).
>      >
>      > A data definition language could contain specific support for
>     binary floating point values used to encode decimal fractions; CDDL
>     currently doesn’t (but support could be added using its main
>     extension point: control operators).
>      >
>      > Grüße, Carsten
>      >


Pete.
-- 
---------------------------------------------------------------------
Pete Cordell
Codalogic Ltd
Read & write XML in C++, http://www.xml2cpp.com
---------------------------------------------------------------------