Re: [Json] JSON Schema Language

Tim Bray <tbray@textuality.com> Mon, 06 May 2019 22:38 UTC

Return-Path: <tbray@textuality.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 7D7A91200CD for <json@ietfa.amsl.com>; Mon, 6 May 2019 15:38:34 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.898
X-Spam-Level:
X-Spam-Status: No, score=-1.898 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=textuality-com.20150623.gappssmtp.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 W7bI2y7rwCtN for <json@ietfa.amsl.com>; Mon, 6 May 2019 15:38:31 -0700 (PDT)
Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (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 BE3FC1200A4 for <json@ietf.org>; Mon, 6 May 2019 15:38:31 -0700 (PDT)
Received: by mail-io1-xd43.google.com with SMTP id u2so9092935ioc.4 for <json@ietf.org>; Mon, 06 May 2019 15:38:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=textuality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=77nQfj4rD82vjFTfd475NTK5G80S6fvhKOmzq+nW9m8=; b=jX0qtz1xIDzM/bBwfxmVI9LSteK87U2ytNKmW/LFFxWUECYDVlFSlrwuflJBTmzuIy oKP+EpY0etCprBhVgZEX9PkeiDatZ9hvRgyLQcVLetMth85lvWCNgHk9ZaYjSzej2Zcj ovf2YCaMcjhpfQiUc7WXjwBVryFl19d+uNp1QtuCiy2M3iDRaC3K5fau2mw5vWX/EN8Q ok5VFOKcigLV49tIwGQ8yJe+OF6HawCSv02VsidS8XiCcpMk8WV4ZeZlSKhZqCXWZObC dqpSBUV2faqgpkCfTDOX2n+8/U4BWWyprFhAzl185DEbxlNgIuv3NlzP/is+hXtvIrl7 szAQ==
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=77nQfj4rD82vjFTfd475NTK5G80S6fvhKOmzq+nW9m8=; b=Wt6LLs1F4sNgbsGP+1KI/9Ej0rKpdvJboQwvJN4o/9ayw1H3UsBNv9pLo2uizdZueR Owr9a7u1ZocngZh2XUd5Oqzgu0JyAqr5As3KFy+cnas8kpIIGjLLs7JuE4a9oU5HE0Af o7UiSk4PqT+6g9l06dNaYJIiGqG/zNstqohtb5gVoExE6AK+NACCqGuvKl9dMQSaQ52T OXJCT+1+GXhSBdPWqJnFMCMc24nWwJlYvK9aL5DPEOXbKKHUnatb4TfGxlXv5s/Ggkcm cyInhvSHMUmSayKmV3w5KvqyiezWcNl6+VwiDYzxOMh3HPvbJuoFjHp1dnZP0JUM5SjC xKpw==
X-Gm-Message-State: APjAAAWmIA09t/pbiDoryQlu/3hne5nyv0QW2dBohnfN2KFVSG2umI9m DyEPyyv6oPxiFK04zg3NO810j0Dn2wX83v1HT9ML9A==
X-Google-Smtp-Source: APXvYqzdc0NogItkYYIM2LDA9MXp+Snggu3/rkyDb34pMsWuQsX62ksStla8KrWEEKEkjRL8d1r2fUkO73+bSM8aBbU=
X-Received: by 2002:a5d:9347:: with SMTP id i7mr561951ioo.84.1557182310952; Mon, 06 May 2019 15:38:30 -0700 (PDT)
MIME-Version: 1.0
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com>
In-Reply-To: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com>
From: Tim Bray <tbray@textuality.com>
Date: Mon, 06 May 2019 15:38:19 -0700
Message-ID: <CAHBU6itE8kub1qtdRoW8BqxaOmzMv=vUo1aDeuAr3HX141NUGg@mail.gmail.com>
To: Ulysse Carion <ulysse@segment.com>
Cc: json@ietf.org
Content-Type: multipart/alternative; boundary="0000000000007ed5eb05883fc22f"
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/jYGIGZBYRaEkiJV21lCP7fYmTOk>
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: Mon, 06 May 2019 22:38:34 -0000

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.

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.

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.

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.

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.





On Fri, May 3, 2019 at 4:59 PM Ulysse Carion <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 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 behind any given specification. Perhaps some other path
> to specification exists?
>
> With kind regards,
> Ulysse Carion
>
> _______________________________________________
> json mailing list
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json
>