Re: [Json] JSON Schema Language

Austin Wright <aaa@bzfx.net> Sat, 04 May 2019 09:37 UTC

Return-Path: <aaa@bzfx.net>
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 91EFE120269 for <json@ietfa.amsl.com>; Sat, 4 May 2019 02:37:11 -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, HTML_MESSAGE=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 (1024-bit key) header.d=bzfx.net
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 z1ZznJgXDuCV for <json@ietfa.amsl.com>; Sat, 4 May 2019 02:37:09 -0700 (PDT)
Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 2223A120273 for <json@ietf.org>; Sat, 4 May 2019 02:37:08 -0700 (PDT)
Received: by mail-pf1-x429.google.com with SMTP id 10so4152805pfo.5 for <json@ietf.org>; Sat, 04 May 2019 02:37:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bzfx.net; s=google; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=HXcD7goiW5AqXVKrZ/fB141MMjjcSgitGR5Xvdqu5l4=; b=E419CFMgJOjdcGieh3Miq2k+l6g5QIArdzN4RhwsTIq6igAyHeyPjFRP0Ulyjg8toV mMo/CwsA9Tl8GF6B835F0zVRibyYStBGQsLBus9m4ZREecTGE8r53Rx8S/OpJyxsnpIs oMeYyvoOa1IztGrJm4EWB9x6qVtg+nSDf4ycI=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=HXcD7goiW5AqXVKrZ/fB141MMjjcSgitGR5Xvdqu5l4=; b=mz2uSA9v5f1q/hpv8aTb6lM7U6CTmF2llVgMWV/esAbIr1mZKKEZ6HeFm7iliFp9ms MP/CoJwCWVqoF9Kvi5GmhP7X8lOJsgXmL5+ka/cP/gXxBNjKxNLRkp5Xdq3ML8RTaAok MO5ph/3OtGV4KI3EJU2iF5+F/w2VLoMtPKVXToPNmqyf+mDqw2JFW9NPjwmHHLvfrgLF JTbYOj+/dn2o2zJ2MuGs77Gr/lm4zHDuLl3AsmqAHXp0MFdvAt+c6lnafAAWInh+diwy 7GWcdpmy3+1xcLfq3tJ4ONFymwtltO7Olf8i1a4Qja2YEBPWqltOzxw9i67OED/xl1cl d6VQ==
X-Gm-Message-State: APjAAAU7HupRSbYskKWSZN96dro5VgK9ydzWhg/Wedz+n5qLHxq7IUXZ OTtQXXv3npfdMMRLe2OTUoYhzg==
X-Google-Smtp-Source: APXvYqyEHQBPchF31ge/ESNQmuaVEfhQFq6QTtukFdluRRw/H1SDg+fKtT1YtU3BxmXbZwwcmgjcpA==
X-Received: by 2002:aa7:80c6:: with SMTP id a6mr18239553pfn.114.1556962628451; Sat, 04 May 2019 02:37:08 -0700 (PDT)
Received: from [192.168.0.116] ([184.101.46.90]) by smtp.gmail.com with ESMTPSA id y8sm4833332pgk.20.2019.05.04.02.37.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 May 2019 02:37:07 -0700 (PDT)
From: Austin Wright <aaa@bzfx.net>
Message-Id: <AD5ABD9C-F5F2-477D-B862-529C890D5472@bzfx.net>
Content-Type: multipart/alternative; boundary="Apple-Mail=_8E5086D1-4A7F-4D22-B597-F0E23FEF6449"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\))
Date: Sat, 04 May 2019 02:36:46 -0700
In-Reply-To: <29CAE1CE-D6CB-4796-B2F2-2095BE921385@tzi.org>
Cc: Anders Rundgren <anders.rundgren.net@gmail.com>, json@ietf.org, Ulysse Carion <ulysse@segment.com>
To: Carsten Bormann <cabo@tzi.org>
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <39682ec8-f993-a44c-d3e2-1638d2c1608f@gmail.com> <29CAE1CE-D6CB-4796-B2F2-2095BE921385@tzi.org>
X-Mailer: Apple Mail (2.3445.104.8)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/DxArLuGLjaa6ZNmBlz4SNhOd6H0>
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: Sat, 04 May 2019 09:37:12 -0000


> On May 4, 2019, at 00:58, Carsten Bormann <cabo@tzi.org> wrote:
> 
> On May 4, 2019, at 06:47, Anders Rundgren <anders.rundgren.net@gmail.com> wrote:
>> 
>> Example: although 10.0 is a valid JSON Number, in system where you expect
>> an integer, this should be flagged as a syntax error.
> 
> 10.0 is an integer number.
> 
> “Schema Languages” operate at the data model level.  In the JSON data model, there is only one kind of number.  
> Of course, the JSON data model is not actually defined in a standard, which is one of the major shortcomings of JSON.
> 

JSON Schema handles this exactly the same way, defining a data model [1]. The lexical representation is surjective onto the data model: as you point out, 10.0 is the same as 10, which is an integer.

The one case where this might fall apart is if significant digits are important, such that 10.0 is different than 10.00 (i.e., 10.00 is more precise by an order of magnitude). However, I’m not aware of any JSON parsers that keep track of the precision of numbers, even ones that support arbitrary precision. I imagine scientific applications would want to store an explicit precision, since they’re not always powers-of-10 (e.g. {value: 32.0, precision: 0.5}).

[1] http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2.1 <http://json-schema.org/latest/json-schema-core.html#rfc.section.4.2.1> "4.2.1. Instance Data Model"

Austin.