Re: [Json] JSON Schema Language

Austin Wright <aaa@bzfx.net> Tue, 07 May 2019 21:13 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 8A80012026E for <json@ietfa.amsl.com>; Tue, 7 May 2019 14:13:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2
X-Spam-Level:
X-Spam-Status: No, score=-2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, 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 JOY13BTMO23R for <json@ietfa.amsl.com>; Tue, 7 May 2019 14:13:36 -0700 (PDT)
Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 ADC54120291 for <json@ietf.org>; Tue, 7 May 2019 14:13:36 -0700 (PDT)
Received: by mail-pg1-x530.google.com with SMTP id h1so8940709pgs.2 for <json@ietf.org>; Tue, 07 May 2019 14:13:36 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bzfx.net; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=WyXq5PbRg+7eDkssdpuovLxPibb3sKY08+w7VIzmHm4=; b=PISJjtYvFKPMA1Ce8EpKF3gmvr7Ao2/jEKAnmde3X1Q9GakNI14q0v6cx+8c0og7JQ SgcnXtNZPmU6txGd7hWrXukTWOXNZuoXrZCr92ybgFgLxEWVcQhXGTobFNpyN/I1tsFW J5arsh5MwDklQ9g2s7PnHVVYIlcgwTtM0zVh0=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=WyXq5PbRg+7eDkssdpuovLxPibb3sKY08+w7VIzmHm4=; b=PmC4UibEWahM6haNELLYyd/92YDHIWGJmNrFjU7yXAjd6BSXBHdCgzl2KSWwTTB9H/ hhZcuech2aqWjHUthoZbInDE7FtWFpGGTTGeWSb6RTaHxkvQHWc7mzl5L2QfoRfaUsTD Cj05PSp3kEIdAGCpOuYZ1LGwFd1w8q4VsBlmQo6SuOMaqaI9t59rWYVdbSZ7Ex3e8UIr 1svHM6F1nAkAwdpV5ZHuMxpJE3Ve26qEWkWNRqpB19mOhy/Mik7+LUoGVkwPyPOIYHZ6 lBSU/Qz/x3gtBTGrWxwzP2TJEtoNwQ4LF0my90Hvo+MEf+Nom0fcfxOWqx/fzM6+nFV8 oSMg==
X-Gm-Message-State: APjAAAWsS20LRv9WQfui6B2Pzw3CSFW30xSTzLzsixwW14/iNe5H6KJu RKZJxVr3I95GlhYSiqVZM6rYlw==
X-Google-Smtp-Source: APXvYqxl0yIrDhKE0H7t0Jq+o4c9VvpjnguIPaUDmXr8P4ISgF5Tjnt3unW84zueMno/iFOMZUGAhw==
X-Received: by 2002:a62:b411:: with SMTP id h17mr43681073pfn.61.1557263615946; Tue, 07 May 2019 14:13:35 -0700 (PDT)
Received: from [192.168.0.175] ([184.101.46.90]) by smtp.gmail.com with ESMTPSA id j16sm17391810pfi.58.2019.05.07.14.13.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 14:13:35 -0700 (PDT)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\))
From: Austin Wright <aaa@bzfx.net>
In-Reply-To: <20190507154201.GP21049@localhost>
Date: Tue, 07 May 2019 14:13:33 -0700
Cc: Anders Rundgren <anders.rundgren.net@gmail.com>, Tim Bray <tbray@textuality.com>, json@ietf.org
Content-Transfer-Encoding: quoted-printable
Message-Id: <CEF72901-5077-4305-BA68-60624DCE952D@bzfx.net>
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <CAHBU6itE8kub1qtdRoW8BqxaOmzMv=vUo1aDeuAr3HX141NUGg@mail.gmail.com> <77994bdb-a400-be90-5893-b846a8e13899@gmail.com> <20190507154201.GP21049@localhost>
To: Nico Williams <nico@cryptonector.com>
X-Mailer: Apple Mail (2.3445.104.8)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/ard8mJzSs4KIJZgEGfkBxgysFnE>
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 21:13:45 -0000


> On May 7, 2019, at 08:42, 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.

I would put it slightly differently: While JSON doesn’t define any concept of an “integer”, applications that encode integers (e.g. uint32_t or similar) might conceivably emit it with the "frac” production (using a trailing decimal and zero); this is not ambiguous, and in the interest of being liberal in what you accept, parsers shouldn’t produce any error.

> 
> Nico
> -- 
> 
> _______________________________________________
> json mailing list
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json