Re: [Json] JSON Schema Language

Carsten Bormann <cabo@tzi.org> Sat, 04 May 2019 09:42 UTC

Return-Path: <cabo@tzi.org>
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 0825B120273 for <json@ietfa.amsl.com>; Sat, 4 May 2019 02:42:33 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Level:
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
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 TMVRwBhD1DNG for <json@ietfa.amsl.com>; Sat, 4 May 2019 02:42:31 -0700 (PDT)
Received: from smtp.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id F3CC3120279 for <json@ietf.org>; Sat, 4 May 2019 02:42:30 -0700 (PDT)
Received: from [192.168.217.106] (p54A6CC75.dip0.t-ipconnect.de [84.166.204.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.uni-bremen.de (Postfix) with ESMTPSA id 44x3v907q1zyZ4; Sat, 4 May 2019 11:42:28 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <AD5ABD9C-F5F2-477D-B862-529C890D5472@bzfx.net>
Date: Sat, 04 May 2019 11:42:28 +0200
Cc: Anders Rundgren <anders.rundgren.net@gmail.com>, json@ietf.org, Ulysse Carion <ulysse@segment.com>
X-Mao-Original-Outgoing-Id: 578655745.34218-e5ed096af226d277a7d768899027ac67
Content-Transfer-Encoding: quoted-printable
Message-Id: <DA1767B8-22D6-4EA9-8112-4B36B79E9039@tzi.org>
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <39682ec8-f993-a44c-d3e2-1638d2c1608f@gmail.com> <29CAE1CE-D6CB-4796-B2F2-2095BE921385@tzi.org> <AD5ABD9C-F5F2-477D-B862-529C890D5472@bzfx.net>
To: Austin Wright <aaa@bzfx.net>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/bV9M3AbVbrO9oolZC3u4aOdYmtc>
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:42:33 -0000

Curious:

On that web page, it also says “For consistency, integer JSON numbers SHOULD NOT be encoded with a fractional part.”

What does that mean?

Grüße, Carsten


> On May 4, 2019, at 11:36, Austin Wright <aaa@bzfx.net> wrote:
> 
> 
> 
>> 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 "4.2.1. Instance Data Model"
> 
> Austin.