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

Anders Rundgren <anders.rundgren.net@gmail.com> Fri, 02 August 2019 13:41 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 2E2231200F4 for <json@ietfa.amsl.com>; Fri, 2 Aug 2019 06:41:41 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 3.001
X-Spam-Level: ***
X-Spam-Status: No, score=3.001 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, GB_SUMOF=5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no 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 6b_BaBQY85jV for <json@ietfa.amsl.com>; Fri, 2 Aug 2019 06:41:39 -0700 (PDT)
Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 7BD5E120088 for <json@ietf.org>; Fri, 2 Aug 2019 06:41:39 -0700 (PDT)
Received: by mail-wr1-x432.google.com with SMTP id n9so77341050wru.0 for <json@ietf.org>; Fri, 02 Aug 2019 06:41:39 -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=jpP5sKegapWVTyUcLx3gUI5FBa6lsPKBXsa3vvmlEwQ=; b=j2Wze92aw8CVLuumqVmXUA398afmzQoxXrNJ/UiJLa1a/gsi5eXo1ItEWaZS46UO4h LIDWiocRwIaZxkAOZ6777PmhCdXKoyYd71VWP/xmnwdaXbfLUGiqTkIIRfoPfGP6mAkM Rf8Sg4JIY3BT/IwAyyF8JkbmEG28AFH4Pa2ubrMfFDqEpBzX4uHE+FZdwBz9VE+sSME1 5Tv5KHQLYRoDs3JzG7qztpd0JhI+PcxdvGQjuk91sYCJ18aQyprY6EWldosQT/3QkXz3 YvLNmFRETmJX67G8F7kt355ou9ts95eTtuS0ycA9N8APRZ1qHqe8an9WYCD3Hcc12HvC XvSQ==
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=jpP5sKegapWVTyUcLx3gUI5FBa6lsPKBXsa3vvmlEwQ=; b=CPDduHxZ0UEZ4VjxbKQAXmfhhP7lzm9mrqfOqHAYu0KRp3pPbNY9NND7394CCQUfb6 nww9yMiufH1Hsu7yn5cIOBuOVqO3YkfgX3Pj1Qwzi4e49Us/+Ul+2zvxOek872Gzuysm NkPCtj0MuEXiOz3LVRtTEcPaGZQBiRyphBPPxst0Nub1+sdDEEayjb6re63BmNuF6O+W ozzRAVyzRIm3qK7tS8syi01olCU1NcLZbm/KUy8IWQKq0O5lxYNzrbZf3007BkBJD86p uJdbi7lPSHXcy9UIs5OFxIfdnyOLrUkb/Sb0iVGB6ly9hYkDz69jh8MdTH/B0yqRW1k5 KHXA==
X-Gm-Message-State: APjAAAUEzs9IophOF7r6SEZIe9YTXmgbvrbPXEMX4GegaUvn8Mhg1XVc IQM8smEsxtDRVHPAwutI5abtxnLT
X-Google-Smtp-Source: APXvYqwNFBZ1+TaZBo4e2FYgeBcv6a17i/J32CLVqHZ8CX1sQmcv6L2gHm0/yFyBG2DuMuyS6pPM+g==
X-Received: by 2002:adf:de08:: with SMTP id b8mr9955947wrm.282.1564753297384; Fri, 02 Aug 2019 06:41:37 -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 e3sm89032535wrs.37.2019.08.02.06.41.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Aug 2019 06:41:36 -0700 (PDT)
To: Pete Cordell <petejson@codalogic.com>, Ulysse Carion <ulysse@segment.com>
Cc: 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> <6c13347a-b64b-c43e-67be-e704450025e4@codalogic.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <b0f685b4-dce8-8647-fad9-1926f441633a@gmail.com>
Date: Fri, 02 Aug 2019 15:41:34 +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: <6c13347a-b64b-c43e-67be-e704450025e4@codalogic.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/sBVjFD5Czobj5QAR6XaGAVcUdlU>
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 13:41:41 -0000

Cool!

On 2019-08-02 13:00, Pete Cordell wrote:
> 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.
>