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

Ulysse Carion <ulysse@segment.com> Fri, 02 August 2019 04:40 UTC

Return-Path: <ulysse@segment.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 D345E1200A1 for <json@ietfa.amsl.com>; Thu, 1 Aug 2019 21:40:12 -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, GB_SUMOF=5, HTML_MESSAGE=0.001, 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 (1024-bit key) header.d=segment.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 1PDqzfhD4F5Q for <json@ietfa.amsl.com>; Thu, 1 Aug 2019 21:40:10 -0700 (PDT)
Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 91E40120074 for <json@ietf.org>; Thu, 1 Aug 2019 21:40:10 -0700 (PDT)
Received: by mail-io1-xd34.google.com with SMTP id k8so149459359iot.1 for <json@ietf.org>; Thu, 01 Aug 2019 21:40:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=segment.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Jw+qdLBhyfGwqG4PmlJlYCO/zBm3CW+BRhBMdGEsodE=; b=gq6xqpJE37lmG8i0++5iC/WMYTZ5toznIzFBfPNFIFL7RMDc13Lge9WK5vc3J6onPv LdMFP4gxXcGRic8+dJXUi8DvDNgpu2opReW7tn9hh+X2AG8t9DEP/SFhLig8exzonQji 1h+chk+tUNCpPdq5F1nUyL3d2EwmcidTLhymA=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Jw+qdLBhyfGwqG4PmlJlYCO/zBm3CW+BRhBMdGEsodE=; b=QobNH/M2TEP+cuR92LE3HHIQbs3Nyq3sZs822/ROdMK4qw6pXjbQ2Bm+ihQufFy/zw U43pHVkdjgLz6bU24Uuyx03WxNtjz7YRdJ/JrdY6znnvuapTB4WAPRWy8DP7i31ssvIf GzwzzNL7PEgcXrK2OXJDwC+JPEDMZ9y4+LKglTD2SxSylllyiZVvmCL9rnx+dnIalVhU TyBzzpATZDgD+meMNK2A7QL4yRU5t0TLEf48Iv8Jy/lbehWBgj3uWYMfGS7nki87oN+3 GqVrK6+Y71ausUovnchUGZcGJVWHQNIEx4cvub2r0OEVCV5pMM7XE2DK8g3KuOEFnzS5 lClQ==
X-Gm-Message-State: APjAAAVBopIYwYx4D/r/YfT0t2evFNJIl6O4R2tWoaDCcc4/tQ17vvHr YEgQIZ9uToLn6U8ipPJWJJihncT3lcc5/bVYHzY6Hg==
X-Google-Smtp-Source: APXvYqwc5biyB5MmDlR4ptddGT2RF3MzKC/tnNsj1RAMn6wxAQy+mEMg5cptuI8QN39hIJNSRvEhXBPJBoLyiOIRSq4=
X-Received: by 2002:a6b:dc08:: with SMTP id s8mr2525510ioc.209.1564720809795; Thu, 01 Aug 2019 21:40:09 -0700 (PDT)
MIME-Version: 1.0
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>
In-Reply-To: <df86cce7-f6f4-2077-6076-6d550368c6f6@gmail.com>
From: Ulysse Carion <ulysse@segment.com>
Date: Thu, 01 Aug 2019 21:39:58 -0700
Message-ID: <CAJK=1Rh3mtXxB2iz-HYZ1xzZ8BUqFs2FX8CnE+xxyr7733784A@mail.gmail.com>
To: Anders Rundgren <anders.rundgren.net@gmail.com>
Cc: Carsten Bormann <cabo@tzi.org>, John Cowan <cowan@ccil.org>, JSON WG <json@ietf.org>, "Manger, James" <James.H.Manger@team.telstra.com>
Content-Type: multipart/alternative; boundary="0000000000000a9194058f1af49c"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/eZzaCbb8DuYhQXPP3yMld11qUNE>
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 04:40:13 -0000

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?

On Thu, Aug 1, 2019 at 12:54 PM Anders Rundgren <
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> 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
> >
>
>