Re: [Json] JSON Schema Language

Anders Rundgren <anders.rundgren.net@gmail.com> Mon, 06 May 2019 06:33 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 9F1C51200C3 for <json@ietfa.amsl.com>; Sun, 5 May 2019 23:33:14 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.999
X-Spam-Level:
X-Spam-Status: No, score=-1.999 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham 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 yZS9PI-ucEKl for <json@ietfa.amsl.com>; Sun, 5 May 2019 23:33:12 -0700 (PDT)
Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (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 8B47012008D for <json@ietf.org>; Sun, 5 May 2019 23:33:12 -0700 (PDT)
Received: by mail-wr1-x42c.google.com with SMTP id w12so2215475wrp.2 for <json@ietf.org>; Sun, 05 May 2019 23:33:12 -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=IzUUI9iCtrldELUQXGq+i8oW5btYR02XjhPh0wrbZbY=; b=QXpLYU1Dp7Po0q9Es7XkxTEvJekYkTHI0MSDmFAQLcpnopZY1lzk0C6VwikXXBK5L1 p96691R1sf4+yHU4xCOvl3s4yt+ulmyS7dZUaHB0itBfQEcK2mSWqeSUz+2hnxFK724w WWq4mhzamZTu8s3oLlwsVdOYke5OchqXL7KeQ/InSEx452skM3ZF9/it6zyeOjF4UILv IcWgVwiA7SSWXkl8bBY+Lp0DCkLG5gsUj0uP0TV+LkheEIrFdB2nrG/w5T63hDEtI0OP AMDIveD7qJU04xWgmCRKgJrmkqjlovWtlZJEssE1LlXeiLoN7ZUm9c25M/AdZQLZXBGL bPWg==
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=IzUUI9iCtrldELUQXGq+i8oW5btYR02XjhPh0wrbZbY=; b=lmckuN6C5n6eIqCNugZqtIRJkVi/yf22+RsGGG1DQolOfWR43UweVwvt2o1moACwbD ny7RVaOg0FOARRKi72D9P/hnK2O+4ERM4iuKuaV0nbnv3NxNtzPNAClZ1MaMAGuyd8mW r05vHFJIzXV9jEv9UVToLv/Z5akrr1Hg2453DZ/kQRAP18c+z3HPScebKIAxavoAKUPS ZSWO+ErqZ7OpgGbCci2g7o3tthsBp9VRWcf7rIhQS/kzZuYcyHR74of8HMgFFgBVArPG 8ec+jog7tEmgek3wWQDmWzXvoH92YQ7XLoLuP8m6ABL1XNnzoXv/mWrcCe/IzSA2sph/ R8RQ==
X-Gm-Message-State: APjAAAUphZz2/2o86OSEQIzcxg6wnWfKMrhTWZWUbRVVXnRJ2H356ECJ 7yhhvngEBs77I/5jN9qxtR4=
X-Google-Smtp-Source: APXvYqyi0mZQrVxe0WCl1ALRUWIoCnwS3uNaiItjvLsQXyrLucoZxC5H97UCTPm8UpzWxfgR916JpA==
X-Received: by 2002:a5d:4f88:: with SMTP id d8mr1169948wru.34.1557124390987; Sun, 05 May 2019 23:33:10 -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 z14sm1013021wrr.34.2019.05.05.23.33.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 May 2019 23:33:09 -0700 (PDT)
To: John Cowan <cowan@ccil.org>, Henry Andrews <henry@cloudflare.com>
Cc: json@ietf.org, Austin Wright <aaa@bzfx.net>
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <39682ec8-f993-a44c-d3e2-1638d2c1608f@gmail.com> <20190505053921.GA21049@localhost> <ac285e33-0ddc-3b96-fb50-de9b65f40c0e@gmail.com> <20190505070023.GB21049@localhost> <56070772-de6f-2553-94c0-df75c08b4c80@gmail.com> <20190505163626.GC21049@localhost> <CAD2gp_TZYYBTnfd3v6mW2DxjEZxA9nZ-tve_18Gi86gTx8ZcxQ@mail.gmail.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <11a605da-0181-a3db-d6f0-e71eb1c1db61@gmail.com>
Date: Mon, 06 May 2019 08:33:06 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1
MIME-Version: 1.0
In-Reply-To: <CAD2gp_TZYYBTnfd3v6mW2DxjEZxA9nZ-tve_18Gi86gTx8ZcxQ@mail.gmail.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/OHoRYhyaDOdLzFL4OfVVWs4p0tk>
Subject: Re: [Json] JSON Schema Language
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: Mon, 06 May 2019 06:33:14 -0000

On 2019-05-05 19:05, John Cowan wrote:
> The Scheme language makes very clear distinctions here.  Integers are a subset of rational numbers, which are a subset of real numbers, which are a subset of complex numbers, and there are predicates for detecting any of them (normally `complex?` is the same as `number?`, but if you want to add quaternions you can).
> 
> Orthogonal to this, there are exact and inexact numbers: a numeric literal can be explicitly marked as either one, but the default is that a number with a decimal point or exponent is inexact, and without either it is exact.  Mixed exactness operations produce inexact results unless the implementation can prove that the inexactness can't matter: the product of 5.0 (inexact) and 0 (exact) can be either exact or inexact.
>

That's the theory.  In practice, using the most widely deployed JSON parser there is (ECMAScript's JSON.parse()), an exact JSON Number like 555555555555555555555555555555 is truncated to 5.555555555555555e+29.  To cope with this, lots of JSON users (as well as IETF standards like RFC7515) have since years back rather turned to a JSON subset sometimes referred to as I-JSON (RFC 7493).

Using I-JSON, numbers that cannot be reliably represented by IEEE-754 double precision are serialized as JSON Strings [1]. This permits hassle-free, cross-platform JSON messaging.

https://tools.ietf.org/html/draft-handrews-json-schema-01 and "its partner in crime" the Open API does not take this in consideration.

Thanx,
Anders

1] There's actually quite a bunch of established String-serialized formats for BigIntegers out there including Decimal, Base64, Base64Url, and Hexadecimal.