Re: [Json] JSON Schema Language

Peter Patel-Schneider <pfpschneider@gmail.com> Tue, 07 May 2019 16:05 UTC

Return-Path: <pfpschneider@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 1C9E012018B for <json@ietfa.amsl.com>; Tue, 7 May 2019 09:05:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.998
X-Spam-Level:
X-Spam-Status: No, score=-1.998 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, 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 (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 CafD5jiYY2eL for <json@ietfa.amsl.com>; Tue, 7 May 2019 09:05:46 -0700 (PDT)
Received: from mail-ua1-x92f.google.com (mail-ua1-x92f.google.com [IPv6:2607:f8b0:4864:20::92f]) (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 5E018120181 for <json@ietf.org>; Tue, 7 May 2019 09:05:46 -0700 (PDT)
Received: by mail-ua1-x92f.google.com with SMTP id s30so6216329uas.8 for <json@ietf.org>; Tue, 07 May 2019 09:05:46 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Gt/tkBbMlGVX42gipGAJtvqHRy0OYgcX2RCX0e9eMrI=; b=RCJT2Xl20jbLFfBO1LzK9iEvjdDktg+VlHOnkrnDE0a+GoN29b3rOOcF3PJBgVkDpm Q9t7HOLX2i999oDpRIQ02x99uDNn9PK/YzOtt0taDb535aPTM33XrBiihAoXwiq0y3CQ YlnQ9++KqKI33GGha/jMRA6/0SC14kRsEtxDKXgYVeqodFbwpjLNhLsYzmHBIUQp96kZ gXFV71Quaw4R2YtnMnqEJpRwnuDntFYeL5W2SNvfUOaOCHozyra348dxsIiglfJBBxm3 e93g+1Chy0FD7bffJjCYL0UwQFeVHB/DAbzjuadzgXRg1gNdqlAYdHTQY/zV1giPMn/v fO4w==
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=Gt/tkBbMlGVX42gipGAJtvqHRy0OYgcX2RCX0e9eMrI=; b=sEWXbXutEhOxwBjksfXGxUpAPvpQ0mwztCB9w3hWtaaFTf0/ccrTIE8C/XjNew2o9z pI4sgGxSYoeE4qSMsc3DVvEIr72coYB0LmoHgyzJXFcu6DT1pwiBezo7bnOjQ4tQJ0+F ZIbBhbnNPxmL8I78KM+kJfPHH7/ZW8kpjBpiuHGznta1K/88jXWCSGQ++vbaKwBpvwtM LBwzcNLFkDPSOWI9W7luV+3yn7fgklgHJvP0kkOAyimD9SFjJFgY2mAaYiHBJ4mLFaR8 Gp/Bz+xARZfX7KJawnqR1avqBFrSJ4aAwMIRKZy0HwKE+IgP7bs490Wf5w9FhceKNJMg MkwQ==
X-Gm-Message-State: APjAAAVoYxAN2AkFVpnzyLB6TTda0+IK3Rf3RRwHZtx7+r5wHn/gIp4P gCXQXPxZsOqMf7Vvd7H5xG3cMraGYszchUPoGHs=
X-Google-Smtp-Source: APXvYqwhjqX0aLQBZQdI5JWVNxuqmMEfY12tFu9FiYd08pc6SmY/85mHJ96qPaeY4+jVu0N7I9GGNh8oSAp1gx7v2YU=
X-Received: by 2002:ab0:30a1:: with SMTP id b1mr5489371uam.104.1557245144870; Tue, 07 May 2019 09:05:44 -0700 (PDT)
MIME-Version: 1.0
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <CAHBU6itE8kub1qtdRoW8BqxaOmzMv=vUo1aDeuAr3HX141NUGg@mail.gmail.com> <77994bdb-a400-be90-5893-b846a8e13899@gmail.com> <20190507154201.GP21049@localhost>
In-Reply-To: <20190507154201.GP21049@localhost>
From: Peter Patel-Schneider <pfpschneider@gmail.com>
Date: Tue, 07 May 2019 09:05:33 -0700
Message-ID: <CAMpDgVxWOk3UqcaFjUaQSTFxnpVrnT21qtwD_vuiybw1cE0JPw@mail.gmail.com>
To: Nico Williams <nico@cryptonector.com>
Cc: Anders Rundgren <anders.rundgren.net@gmail.com>, Tim Bray <tbray@textuality.com>, JSON WG <json@ietf.org>
Content-Type: multipart/alternative; boundary="000000000000b036d805884e637f"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/axkbGXVh_LU9T_NVvrH0Z5anZD8>
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: Tue, 07 May 2019 16:05:50 -0000

I was looking through the JSON specification and nowhere could I find a
reference to integers.  That indicates to me that any conversion from JSON
numbers to integers has to be done outside of JSON.  Conformant
implementations of JSON are thus free to do conversion from JSON numbers to
integers in whatever way they want.  There is a cost in doing the
conversion differently than common JSON implementations do, but that is a
different discussion.

I could, if I wanted, use JSON numbers to represent inexact numbers where
the precision of is +-1 in the last digit, so 4 is different from 4.0 is
different from 4.000000.  I have to be very careful that the only JSON
texts I allow are ones that are created with this understanding of numbers,
but I haven't done anything that violates the JSON specification.

Peter F. Patel-Schneider



On Tue, May 7, 2019 at 8:42 AM Nico Williams <nico@cryptonector.com> wrote:

> On Tue, May 07, 2019 at 06:44:49AM +0200, Anders Rundgren wrote:
> > On 2019-05-07 00:38, Tim Bray wrote:
> > > I mostly fail to understand the debate about jq and integers and so
> > > on. Clearly, the following is a valid JSON text and will be parsed
> > > successfully by any JSON parser.
> > >
> > > {
> > >   "foo": 3.0
> > > }
> > >
> > > I imagine that most schema-driven software would first deserialize
> > > it into a tree, probably something like Jackson ObjectMapper's
> > > JsonNode, and then apply schema constructs to the tree.   I would
> > > hope that a sane schema would accept this whether a top-level "foo"
> > > was required to be an integer or double or most other flavors of
> > > number, and reject it if "foo" was required to be a string or
> > > boolean.
> >
> > Here we have a little problem.  There are already quite popular
> > parsers out there flagging 3.0 as an invalid integer when explicitly
> > parsing for an integer[*].  Personally, I consider this as right thing
> > to do in a schema as well.  Letting one or two rotten eggs (=JSON
> > serializers that output Numbers that also represent exact integers
> > with fractions) set the bar for the other 99.9% doesn't seem right to
> > me.
>
> Those parsers are broken.
>
> > > Put another way, no JSON schema spec can change the definition of
> > > what JSON is, or make the built-in type system anything but what it
> > > is.
> >
> > I don't think anybody is actually proposing that; only mapping things
> > that doesn't have a specific representation in JSON like integers.
>
> Integers do have a specific representation in JSON, and anything that
> precludes generic encoders that might emit 10.0 where a peer parser will
> reject that as not-an-integer *is* a change to JSON.
>
> Nico
> --
>
> _______________________________________________
> json mailing list
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json
>