Re: [Json] JSON Schema Language: extensibility and unspecified properties

Carsten Bormann <cabo@tzi.org> Tue, 13 August 2019 05:31 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 74136120088 for <json@ietfa.amsl.com>; Mon, 12 Aug 2019 22:31:52 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.198
X-Spam-Level:
X-Spam-Status: No, score=-4.198 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=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 txrjblTeTHRE for <json@ietfa.amsl.com>; Mon, 12 Aug 2019 22:31:50 -0700 (PDT)
Received: from gabriel-vm-2.zfn.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 CF4F0120077 for <json@ietf.org>; Mon, 12 Aug 2019 22:31:49 -0700 (PDT)
Received: from [192.168.217.110] (p548DCCB9.dip0.t-ipconnect.de [84.141.204.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gabriel-vm-2.zfn.uni-bremen.de (Postfix) with ESMTPSA id 4671YH6bSfz10pP; Tue, 13 Aug 2019 07:31:47 +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: <CAJK=1RiE_+nHkeB77DericN498w1v9mf2hsBgnQtgsZTVM9N9A@mail.gmail.com>
Date: Tue, 13 Aug 2019 07:31:47 +0200
Cc: JSON WG <json@ietf.org>
X-Mao-Original-Outgoing-Id: 587367104.3199871-76b87a4c43c17fedf4fe43effac15e3e
Content-Transfer-Encoding: quoted-printable
Message-Id: <118F844A-453D-497D-8107-CF2BD05AC313@tzi.org>
References: <CAJK=1RhXp85cz-pOAQPw2JM=CYHgGSygj4Hw0spht56jbzQE2g@mail.gmail.com> <53094378-B559-49E1-B42B-54FBA8BC35AA@tzi.org> <CAJK=1Rj6Q3CvpF9aYML=47SF_XP49=O2hLhcBo8gZCb73C0RAw@mail.gmail.com> <FDB93E41-9D7D-4BF2-8D01-F4D075774848@tzi.org> <CAJK=1RiE_+nHkeB77DericN498w1v9mf2hsBgnQtgsZTVM9N9A@mail.gmail.com>
To: Ulysse Carion <ulysse@segment.com>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/o87u5y6n4lFMpHNxFqG0HvGoOCM>
Subject: Re: [Json] JSON Schema Language: extensibility and unspecified properties
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: Tue, 13 Aug 2019 05:31:52 -0000

On Aug 13, 2019, at 07:03, Ulysse Carion <ulysse@segment.com> wrote:
> 
>> However, it seems bizarre to support int8, int16, and int32, but not JSON’s generic interoperable integers.
> 
> Supposing we add int53 to JSL, do you picture code generators
> producing int64_t/long for {"type": "int53" }? Does that mean that,
> before serializing an int64_t to something marked as int53 in JSL, the
> application must first do an extra bounds check? Today, it's fairly
> easy to generate code from JSL where serializing is an infallible
> affair. But with int53, that property would be lost, because most type
> systems cannot express int53.

Many type systems don’t have a uint8, either.

> I'm inclined to think this is something better handled by extensions.
> Perhaps someone can define a "intt53" property to do something like:
> 
> { "type": "number", "int53": true }
> 
> The person writing the extension would document that the "int53"
> property indicates whether a number is meant to represent a number in
> the I-JSON range. Applications which don't understand this keyword
> will still do something reasonable -- validate for some sort of
> number, and code generate a "double" -- but applications which care
> about this can handle this case specially. It also signals an intent
> about how the number will be used.

Again, the same is true for uint8.

(This opens the whole “types vs. subtypes” discussion.)

> I expect this sort of approach is how JSL may need to handle
> big-number encoding schemes. There are so many different ways approach
> that problem, and I think JSL is most useful if it establishes an
> uncontroversial foundation, and then lets additional, out-of-spec
> keywords tighten the schema further in a way which most folks don't
> care about, and hence don't want to have to implement.
> 
> Does that seem like a reasonable approach?
> 
>> Actually, that’s something JSON can’t deal with.
> 
> By this you mean that JSON prescribes "all numbers are doubles", and
> so integers aren't really a good thing to try to foist onto JSON's
> syntax?

Integer is a mathematical concept.  JSON does not have a problem with that.

The problem comes in when applications arbitrarily restrict the syntax.

Not allowing a fractional or exponent part is akin to requiring two spaces of indentation before or a newline after a number.

It gets worse when syntax variations are assigned different application semantics.
(E.g., I’m aware of at least one “JSON-based” syntax where a string that starts with “\u0073” has semantics different from a string that starts with “s”.)

You can’t do that to a format like JSON and still be part of the JSON ecosystem, because generic JSON decoders discard these syntax features, and generic JSON encoders generally can’t produce them.

>> MS-Excel has repeatedly taught me that my university phone number is 2.1863921e7, but people still manage to call me :-)
> 
> Could you expand what you mean here? I realize no joke is funny enough
> to survive explanation, but I’m afraid I'm perhaps missing your point.

Well, my phone number is 21863921, but some spreadsheets consider this a large number and turn it into an NR3 number…

Grüße, Carsten