Re: [Json] JSON Schema Language

Nico Williams <nico@cryptonector.com> Mon, 06 May 2019 17:02 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 B3CBF120188 for <json@ietfa.amsl.com>; Mon, 6 May 2019 10:02:10 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.002
X-Spam-Level:
X-Spam-Status: No, score=-2.002 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, RCVD_IN_MSPIKE_H2=-0.001, 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 upsf1PNMoq7Z for <json@ietfa.amsl.com>; Mon, 6 May 2019 10:02:08 -0700 (PDT)
Received: from cichlid.maple.relay.mailchannels.net (cichlid.maple.relay.mailchannels.net [23.83.214.36]) (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 86274120071 for <json@ietf.org>; Mon, 6 May 2019 10:02:08 -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 7621C142B26; Mon, 6 May 2019 17:02:07 +0000 (UTC)
Received: from pdx1-sub0-mail-a48.g.dreamhost.com (100-96-79-6.trex.outbound.svc.cluster.local [100.96.79.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D3606142A85; Mon, 6 May 2019 17:02:06 +0000 (UTC)
X-Sender-Id: dreamhost|x-authsender|nico@cryptonector.com
Received: from pdx1-sub0-mail-a48.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); Mon, 06 May 2019 17:02:07 +0000
X-MC-Relay: Neutral
X-MailChannels-SenderId: dreamhost|x-authsender|nico@cryptonector.com
X-MailChannels-Auth-Id: dreamhost
X-Spicy-Snatch: 509e0e357d315fbb_1557162127323_236342131
X-MC-Loop-Signature: 1557162127323:2701885521
X-MC-Ingress-Time: 1557162127322
Received: from pdx1-sub0-mail-a48.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a48.g.dreamhost.com (Postfix) with ESMTP id 7A70781F4F; Mon, 6 May 2019 10:02:01 -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=XBjqb7lyJ2z4Uo 1SYGogB7Gz+G4=; b=BEIahbBbCfVtmDzM+n4+FcWm3n3MpQt81CXRUZ4/iE1sAT EG6DV5sH7F+UGXBVhwKK37rnVAm+pQwLp+R63ZzVm/rryiwLBpnCSkrxglzFS7fQ aoIEPdoOtm3o1hqoaGzxaq3nKw+MpscLPLkotP9UTtOtuXrHqxOP0pVRDg4wI=
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-a48.g.dreamhost.com (Postfix) with ESMTPSA id DCEBB81F74; Mon, 6 May 2019 10:01:59 -0700 (PDT)
Date: Mon, 06 May 2019 12:01:57 -0500
X-DH-BACKEND: pdx1-sub0-mail-a48
From: Nico Williams <nico@cryptonector.com>
To: Anders Rundgren <anders.rundgren.net@gmail.com>
Cc: Austin Wright <aaa@bzfx.net>, Ulysse Carion <ulysse@segment.com>, json@ietf.org
Message-ID: <20190506170155.GH21049@localhost>
References: <39682ec8-f993-a44c-d3e2-1638d2c1608f@gmail.com> <29CAE1CE-D6CB-4796-B2F2-2095BE921385@tzi.org> <AD5ABD9C-F5F2-477D-B862-529C890D5472@bzfx.net> <DA1767B8-22D6-4EA9-8112-4B36B79E9039@tzi.org> <D21B379B-23CC-48B3-BE10-D2777308E2E0@bzfx.net> <40f80ea0-d130-3f3b-39fa-2c84e802ed55@gmail.com> <35E2623E-753D-4918-8AF4-BF0BC5DE4868@bzfx.net> <6260354b-aca2-e001-7145-148b32658416@gmail.com> <9D90C1F1-6747-4373-93B0-8D51C5B25F1C@bzfx.net> <3a438654-b1ef-ecbd-0fb2-937d8f40f0c9@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Disposition: inline
In-Reply-To: <3a438654-b1ef-ecbd-0fb2-937d8f40f0c9@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: gggruggvucftvghtrhhoucdtuddrgeduuddrjeekgddutdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeffhffvuffkfhggtggujggfsehttdertddtredvnecuhfhrohhmpefpihgtohcuhghilhhlihgrmhhsuceonhhitghosegtrhihphhtohhnvggtthhorhdrtghomheqnecukfhppedvgedrvdekrddutdekrddukeefnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehlohgtrghlhhhoshhtpdhinhgvthepvdegrddvkedruddtkedrudekfedprhgvthhurhhnqdhprghthheppfhitghoucghihhllhhirghmshcuoehnihgtohestghrhihpthhonhgvtghtohhrrdgtohhmqedpmhgrihhlfhhrohhmpehnihgtohestghrhihpthhonhgvtghtohhrrdgtohhmpdhnrhgtphhtthhopehnihgtohestghrhihpthhonhgvtghtohhrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/Bo-KhpVxwCjEeO3soqmMKf9Wxqs>
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 17:02:11 -0000

On Mon, May 06, 2019 at 10:55:56AM +0200, Anders Rundgren wrote:
> On 2019-05-06 09:22, Austin Wright wrote:
> <snip>
> > 
> > Can you elaborate on this? My point is primarily concerned with JSON
> > parsers, not JSON the media type.
> > 
> > Suppose a string were too large to store in memory, most ECMAScript
> > engines would bail with an uncatchable error. The suggestion is to
> > implement this more robustly, like throw an error if a string would
> > be too long, or if a number has too many significant figures;
> > instead of either crashing or silently approximating the number.

What's that got to do with schemas?

> I don't understand this.  A JSON schema is a description of a JSON
> document.  If the description is incompatible with implementations
> that are supposed to parse compliant documents all bets are off.

A schema is not a description of a document but a description of a class
of documents.

I suspect that you think the point of a schema is to allow you to have a
parser that parses straight into an internal representation specifically
derived from the schema, but that is not the only possibility!

It should absolutely be possible to first parse a JSON text with a
*generic* JSON parser, *then* check if the parsed thing meets the
requirements of the schema.  This is a very reasonable thing to do,
especially with general-purpose languages like ECMAScript, or jq that
deal with JSON very naturally.  I object strongly to any JSON schema
that makes this approach not workable.

> > But also, why not build a parser that uses a schema to influence how
> > values are parsed? Suppose you have a dynamically typed language,
> > and want to parse some value, e.g. sometimes as an int, sometimes as
> > a bignum, depending on the property. You might provide a JSON Schema
> > to specify this behavior.
> 
> This sounds like an edge-case but it could be supported by an "any"
> type (although don't particularly see how this could work in a
> cross-platform scenario).

Or a CHOICE.

(Here, again, I have to say that ASN.1 already has all these things, so
we should at least be informed by it before we go off and reinvent that
wheel badly.)

Nico
--