Re: [Json] JSON Schema Language

Anders Rundgren <anders.rundgren.net@gmail.com> Tue, 07 May 2019 04:45 UTC

Return-Path: <anders.rundgren.net@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 70441120041 for <json@ietfa.amsl.com>; Mon, 6 May 2019 21:45:01 -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 6TDp7ACdw0g2 for <json@ietfa.amsl.com>; Mon, 6 May 2019 21:44:58 -0700 (PDT)
Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (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 B866C120020 for <json@ietf.org>; Mon, 6 May 2019 21:44:57 -0700 (PDT)
Received: by mail-wr1-x42c.google.com with SMTP id s15so20175065wra.12 for <json@ietf.org>; Mon, 06 May 2019 21:44:57 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=Tdp51dPUriLJ4v14RSv+di7qcvVkwmx+rmvj/1POEb0=; b=QbgjnybIKFe8R0nwfBv8QFTn8QvTmttN4Tb+HyJp/jDll97PzBzGEpCCew8HC7PBTw ACb7NqzjGQgXl3U/ss20LS1tftJJ2JVhRvvXbs7rUk76tQ+BCE/cFzp8WSDH0gwe4LjW y3acqdC2wF5XymK1UwPY8+UDFKGCUuIxPz3ZZDWffv1Qgm7aqEmRoMOllspKASDffR9G g+3nwf7i318AW5HbYtZsUrBT2iyPx7QNLEHCOp4ha1EPXjmh2N3hlIuedWLX3ye/RCtS IA/4KswumEHYOlwQCaaKqWYhNV9T6Vvt9eKPLOk41W5A7PDVQ1XV16ICx72G87H9wgFI JPDw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=Tdp51dPUriLJ4v14RSv+di7qcvVkwmx+rmvj/1POEb0=; b=Y9wQXpvhMh+m5Vt/Iq3t9A6eroBRx9OSvIy5oqE2jYFnUA1me4ZaWideztO3+I5K8g Qa3FINB9ZaVbM935oZRH5xh2b8LihekiSxhO/ha1yRSZnNWLze5+6R4r2wcHV8ZsKJwQ zBOkAlnpVilzaHPy8mTDE6LbMjxeldSS33epEBUpUVKMZgDLic+e2CIRB0eETKstujdg NZFHmwDqFFz6F9DNED+qROLnk7hzelck2hBM5ANglfv8Z7TZrH/idz5XkUbDHZghTLWg OF3zMUknEbNJOi81BDEW6lV4jXpG/Pa83+J1VGvOUwTfmlDLFSGd8T0P+oblLZbNDABL PgxQ==
X-Gm-Message-State: APjAAAUvAoY2NTfgE27eehdLP3jn88cD+IKLYkdBVQwLQ8bywxGNTfXj Wdxgzw0qg2KRUlYE7KCYr353OTVhBWE=
X-Google-Smtp-Source: APXvYqyMGYC/pgUwAOAg9OQ7kEV5iOwoj7BgwZXbYoTkGn0+dsDPbj+8dsud1Plyp6lQrsX1FwROiw==
X-Received: by 2002:a5d:55cb:: with SMTP id i11mr21697256wrw.187.1557204295632; Mon, 06 May 2019 21:44:55 -0700 (PDT)
Received: from [192.168.1.79] (25.131.146.77.rev.sfr.net. [77.146.131.25]) by smtp.googlemail.com with ESMTPSA id b10sm24075005wme.25.2019.05.06.21.44.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 May 2019 21:44:54 -0700 (PDT)
To: Tim Bray <tbray@textuality.com>
Cc: json@ietf.org
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <CAHBU6itE8kub1qtdRoW8BqxaOmzMv=vUo1aDeuAr3HX141NUGg@mail.gmail.com>
From: Anders Rundgren <anders.rundgren.net@gmail.com>
Message-ID: <77994bdb-a400-be90-5893-b846a8e13899@gmail.com>
Date: Tue, 07 May 2019 06:44:49 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1
MIME-Version: 1.0
In-Reply-To: <CAHBU6itE8kub1qtdRoW8BqxaOmzMv=vUo1aDeuAr3HX141NUGg@mail.gmail.com>
Content-Type: multipart/alternative; boundary="------------8E11B453707C4D4030DFB65B"
Content-Language: en-US
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/-swna0N8uSVHQ07v0CWEsc6jmGQ>
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 04:45:02 -0000

On 2019-05-07 00:38, Tim Bray wrote:
> Hi all.  I haven't got around to reading the draft (but will soon). Prior to that, a few notes:
>
> 1. I'm pretty sure that we need something better than what we have in the area of JSON schemas.  At least, I'm 100% sure that my job at Amazon Web Services would be easier, and our customer experiences would be more pleasant, if we had something.
+1
>
> 2. One thing schemas are useful for is to syntax-check JSON texts that claim to conform to some language specification or another. Obviously no schema can ever completely satisfy this requirement - there are always things in specifications which are semantic and not addressable by schemas - but they can still be super useful.
+1
>
> 3. Another thing they are useful for is for providing help to developers working in strongly typed programming languages. With a well-built schema it is reasonably straightforward to auto-generate nice idiomatic class declarations in modern programming languages, and also to build serializers/deserializers that will move data back and forth between JSON blobs and programming-language constructs, or fail in a clean deterministic way if the JSON fails to match the schema.
+1
>
> 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.

>
> 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.

Anders

*] When for example deserializing JSON into a class definition ("unmarshalling") containing an integer property.

>
>
>
>
>
> On Fri, May 3, 2019 at 4:59 PM Ulysse Carion <ulysse@segment.com <mailto:ulysse@segment.com>> wrote:
>
>     Hello all,
>
>     I have recently published an I-D for what I'm calling JSON Schema
>     Language, a way to validate JSON data's shape, and generate code
>     (i.e., types, classes, docs, etc.) from that shape:
>
>     https://tools.ietf.org/html/draft-json-schema-language-00
>
>     In previous correspondence with this list, Carsten Bormann has noted
>     that this WG has hesitated to prematurely adopt any given proposal,
>     preferring to let them develop until their distinct applications
>     become clear.
>
>     It is my belief that JSON Schema Language does have a clear use-case,
>     one which Tim Bray has articulated clearly here:
>
>     https://www.tbray.org/ongoing/When/201x/2018/09/22/JSON-scheming
>
>     I believe JSON Schema Language solves precisely what Tim describes,
>     while eschewing his concerns with the json-schema.org <http://json-schema.org> project.
>
>     For those inclined toward the concrete, the bottom of this page
>     contains a live demo of JSON Schema Language using the TypeScript
>     implementation:
>
>     https://json-schema-language.github.io/
>
>     The project's GitHub organization also contains the source for a Rust
>     and TypeScript implementation, as well as a full test suite:
>
>     https://github.com/json-schema-language
>
>     With Carsten's note in mind, does there nevertheless exist a path for
>     JSON Schema Language, or something like it, to become an RFC? I
>     appreciate the desire to avoid premature adoption by this WG. I assume
>     this partially stems from caution around throwing the weight of
>     json@ietf.org <mailto:json@ietf.org> behind any given specification. Perhaps some other path
>     to specification exists?
>
>     With kind regards,
>     Ulysse Carion
>
>     _______________________________________________
>     json mailing list
>     json@ietf.org <mailto:json@ietf.org>
>     https://www.ietf.org/mailman/listinfo/json
>
>
> _______________________________________________
> json mailing list
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json