Re: [Json] JSON Schema Language

Nico Williams <nico@cryptonector.com> Wed, 08 May 2019 16:03 UTC

Return-Path: <nico@cryptonector.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 B0ABF12012D for <json@ietfa.amsl.com>; Wed, 8 May 2019 09:03:26 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.001
X-Spam-Level:
X-Spam-Status: No, score=-2.001 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=cryptonector.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 oG-jNqn4GDLO for <json@ietfa.amsl.com>; Wed, 8 May 2019 09:03:24 -0700 (PDT)
Received: from orchid.birch.relay.mailchannels.net (orchid.birch.relay.mailchannels.net [23.83.209.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 24B1F120089 for <json@ietf.org>; Wed, 8 May 2019 09:03:24 -0700 (PDT)
X-Sender-Id: dreamhost|x-authsender|nico@cryptonector.com
Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 334FD342786; Wed, 8 May 2019 16:03:22 +0000 (UTC)
Received: from pdx1-sub0-mail-a33.g.dreamhost.com (100-96-28-9.trex.outbound.svc.cluster.local [100.96.28.9]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 2CF1B341A92; Wed, 8 May 2019 16:03:20 +0000 (UTC)
X-Sender-Id: dreamhost|x-authsender|nico@cryptonector.com
Received: from pdx1-sub0-mail-a33.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.2); Wed, 08 May 2019 16:03:22 +0000
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|nico@cryptonector.com
X-MailChannels-Auth-Id: dreamhost
X-Wipe-Stop: 7d4f5fb37b16a05a_1557331401418_3813076323
X-MC-Loop-Signature: 1557331401418:554141429
X-MC-Ingress-Time: 1557331401417
Received: from pdx1-sub0-mail-a33.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a33.g.dreamhost.com (Postfix) with ESMTP id D4E2180067; Wed, 8 May 2019 09:03:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=cryptonector.com; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=cryptonector.com; bh=1foka0POQFDnzj WKvS9hOaXAwUk=; b=j2V/nKQeSftIGQsc1JDPLJLoy/DQR7jYpgXTJc9r2w7FEc BYOwyaxd8h1n4onEXJTpKEu3VR+by8ixjZBb/A5Vaeqrw3nVRuMfzUuh/sA4rKdz 8drgJv0hiFJDR0cHwK8hhQtTjHCRKlOdm5CrShrnIrDbhQd1Et/4KWmgCZpoM=
Received: from localhost (unknown [24.28.108.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: nico@cryptonector.com) by pdx1-sub0-mail-a33.g.dreamhost.com (Postfix) with ESMTPSA id 2242A80063; Wed, 8 May 2019 09:03:13 -0700 (PDT)
Date: Wed, 08 May 2019 11:03:11 -0500
X-DH-BACKEND: pdx1-sub0-mail-a33
From: Nico Williams <nico@cryptonector.com>
To: Ulysse Carion <ulysse@segment.com>
Cc: Erik Wilde <erik.wilde@dret.net>, Anders Rundgren <anders.rundgren.net@gmail.com>, Austin Wright <aaa@bzfx.net>, Phillip Hallam-Baker <ietf@hallambaker.com>, Tim Bray <tbray@textuality.com>, JSON WG <json@ietf.org>
Message-ID: <20190508160309.GT21049@localhost>
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <CAHBU6itE8kub1qtdRoW8BqxaOmzMv=vUo1aDeuAr3HX141NUGg@mail.gmail.com> <77994bdb-a400-be90-5893-b846a8e13899@gmail.com> <20190507154201.GP21049@localhost> <CEF72901-5077-4305-BA68-60624DCE952D@bzfx.net> <69ea0c99-e983-5972-c0aa-824ddeecb7c4@dret.net> <CAMm+LwjyVjnJuWE4+a9Ea=_X1uuEGuK+O4KojzN3uVQ+s+HqUQ@mail.gmail.com> <058f58a3-dd27-998e-5f54-4874aff5f2f0@dret.net> <20190507221726.GR21049@localhost> <CAJK=1Rj7PBD-bbwvsqgjQQzp4Aoidb-W2q5Lj6asMHHDHaTVYQ@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <CAJK=1Rj7PBD-bbwvsqgjQQzp4Aoidb-W2q5Lj6asMHHDHaTVYQ@mail.gmail.com>
User-Agent: Mutt/1.9.4 (2018-02-28)
X-VR-OUT-STATUS: OK
X-VR-OUT-SCORE: -100
X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduuddrkeefgdeliecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeffhffvuffkfhggtggujggfsehttdertddtredvnecuhfhrohhmpefpihgtohcuhghilhhlihgrmhhsuceonhhitghosegtrhihphhtohhnvggtthhorhdrtghomheqnecukfhppedvgedrvdekrddutdekrddukeefnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehlohgtrghlhhhoshhtpdhinhgvthepvdegrddvkedruddtkedrudekfedprhgvthhurhhnqdhprghthheppfhitghoucghihhllhhirghmshcuoehnihgtohestghrhihpthhonhgvtghtohhrrdgtohhmqedpmhgrihhlfhhrohhmpehnihgtohestghrhihpthhonhgvtghtohhrrdgtohhmpdhnrhgtphhtthhopehnihgtohestghrhihpthhonhgvtghtohhrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/GcgDImS1MslSDWybtG3zT-X4Bhk>
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: Wed, 08 May 2019 16:03:27 -0000

On Tue, May 07, 2019 at 04:57:01PM -0700, Ulysse Carion wrote:
> 1. Considerable ink has been spilled on the question of integers in a
> schema language. The main question has been how such an integral
> constraint should relate to serialization.
> 
> 2. Some have raised questions around the terseness of JSON Schema and
> JSON Schema Language. Proposed alternatives are JCR and CDDL, by their
> respective editors.
> 
> On the first question, I would agree with Messrs. Bormann and Bray,
> who both suggest that a generic JSON parser runs first, followed by a

It's not that "a generic JSON parser runs first, followed by ...", but
that that must be a valid implementation choice.

> second pass over the data to convert the parsed data in the context of
> a schema. On such a view, "3" and "3.0" are typically
> indistinguishable by the time the schema is taken into account.

Correct.

> Bormann aptly notes that the alternative runs the risk of de facto
> forking JSON itself. I don't think there is much more to be said on
> the matter.

Excellent.  I think that's been put to bed now.

> The second question is perhaps more interesting, although it has
> provoked less discussion. I went with JSON as the representation
> because it makes building tooling atop of JSON Schema Language much
> easier, since it doesn't require that the implementor write a parser.

+1

I've been meaning for some time now to create an ASN.1 -> JSON schema
converter.  The idea would be to then use JS or jq to perform additional
analysis / modifications, and generate code.  In particular I'm looking
to express code generation controls using path-like expressions and thus
avoid having to express such controls as commentary or other
modifications to an ASN.1 module.

A similar approach using XML would also work, but then the right tool
would be XSLT/XPath, and I'm not too keen on that, having written a
not-too-trivial XSLT app.

> Such ease of extension is valuable: JSON is widespread largely because
> of how easy it is to build atop of, and we should not readily
> sacrifice this. JSON as the representation also unlocks syntax
> highlighting, formatting, and other such niceties for free.

JSON is a bit awful, honestly, but yes, it has these properties: that is
widely used, somewhat readable and editable, and has a lot of tooling
available.

> Furthermore, and most importantly, using JSON as a representation does
> not preclude later creating a RELAX NG-style compact representation
> later on.
> 
> I would also like to echo Bray's point about the real-world utility of
> such a system. My day-job involves APIs, event-sourcing, and analytics
> messages. In all three, JSON is the lingua franca, and in all three
> considerable tedium is involved in writing and maintaining validators
> and language-idiomatic containers for JSON messages. No
> language-portable solution to this problem exists today, short of
> moving away from JSON toward something like Protobufs or CBOR.

CBOR and other binary JSON formats have the benefit of keeping the data
model, which means that existing tooling can easily be made to interface
with them.

> I'd like to return to the initial question of this thread, this time
> rephrased:
> 
> Are we in agreement that the question of describing JSON, and from
> that description generating validators and idiomatic
> classes/types/etc, is a problem worth solving?

Of course it is.

> Are we in agreement that something along the lines of the proposed I-D
> may be a way we address this problem?

I shall have to read it.

Nico
--