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

Anders Rundgren <anders.rundgren.net@gmail.com> Thu, 01 August 2019 19:54 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 311BC1201D2 for <json@ietfa.amsl.com>; Thu, 1 Aug 2019 12:54:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: 3.002
X-Spam-Level: ***
X-Spam-Status: No, score=3.002 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, URIBL_BLOCKED=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 5YhmXBBPFlP1 for <json@ietfa.amsl.com>; Thu, 1 Aug 2019 12:54:32 -0700 (PDT)
Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 4BE9E1201CF for <json@ietf.org>; Thu, 1 Aug 2019 12:54:32 -0700 (PDT)
Received: by mail-wm1-x32d.google.com with SMTP id p74so65742829wme.4 for <json@ietf.org>; Thu, 01 Aug 2019 12:54:32 -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=jk2AafTvCbJ9EPcerKGhTeCg/utlm+5dH1LwbqA7Ca8=; b=tm6WrU7zO98cWkEu95f5FBgBVTp8hdYSbOo9I5+iJX3KcjK0zrqXz9zRCFz+6HcZoX TQaUrx9LR032ltXl1JufD7rEYzjSoSy72hIYOIYoNyw+lP3bb7vJHNucRheErRsp3UaJ WBVkeZe6xD6hNzBp0l3NWnpEiiz/nfzmffkDk9EFPn7gLKJurIwqHtAixgHBPjbfrgmw mA+jqPuj+F3SPa4p/2SCE6OVwgTD+NheXFN/YN0Ys6Uqy4PJFMpyyJpYcchGeOXQQuJO 847iJKOniAgGw5ZUYuZYYY2xR7Zjb3LJdYcWG/9gdnnuMTFOrJqHthfWciY7O+1peeHA LPag==
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=jk2AafTvCbJ9EPcerKGhTeCg/utlm+5dH1LwbqA7Ca8=; b=SJtcpXQEtUKXB+15k5jdunW99nipSowA2X9FQp1VlJcnjzzz0ZfkMXAu1SvLjCF676 ga6UkrfWY3CXrP6Um9fS9i/FUxxg/eWWZYXLVwsBCiCQSOsYnkhKV9YKyCiIPQ+uq2nI 2bqvJhXGAVAYfPoNURoCb4+PyEsjhZQQoXEs3apvO4KWJUWpPiPkX+XxUlvorNA17PA8 7rTmdoYfWIDDCopAsAseHao6ezQgRdzFIk0ps5k62Kt1JCI0m8GYEPdOAdodYLrsrxkh p6OvN0nHSUO9bpLKJy4mETfnIvcMdAJeDXRhEbOllDP4i/IGvchnJ9GbfAm+ufwPjk1M CY7A==
X-Gm-Message-State: APjAAAWlNiH6NALk4hnNP5kmVWZTxGaKOShuc4rme2jtoE51PWDk2raB utehiIrvZbhKhB64E9gwYq8=
X-Google-Smtp-Source: APXvYqxKq3nEMQ2kcGyAuz7TFF/qgWa8Y/CjHoqNALLuOuchL2ID8gLzd25R9H5NLozI8AuB/1vB8Q==
X-Received: by 2002:a1c:7e85:: with SMTP id z127mr294625wmc.95.1564689270725; Thu, 01 Aug 2019 12:54:30 -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 j33sm156524141wre.42.2019.08.01.12.54.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 12:54:29 -0700 (PDT)
To: Carsten Bormann <cabo@tzi.org>, John Cowan <cowan@ccil.org>
Cc: Ulysse Carion <ulysse@segment.com>, JSON WG <json@ietf.org>, "Manger, James" <James.H.Manger@team.telstra.com>
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>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <df86cce7-f6f4-2077-6076-6d550368c6f6@gmail.com>
Date: Thu, 01 Aug 2019 21:54:27 +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: <5ECB215B-AA05-47AB-AC8F-F14A74A46FEE@tzi.org>
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/oEZcUZUTRqBaC5utBh_5xzHzpRM>
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: Thu, 01 Aug 2019 19:54:34 -0000

On 2019-08-01 21:07, Carsten Bormann wrote:
> On Aug 1, 2019, at 18:08, John Cowan <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
>