Re: [Json] Another problematic JSON Schema use-case

Andrew Newton <andy@hxr.us> Wed, 25 May 2016 06:52 UTC

Return-Path: <andy@hxr.us>
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 91DC012DA5B for <json@ietfa.amsl.com>; Tue, 24 May 2016 23:52:13 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.6
X-Spam-Level:
X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=hxr-us.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 W6UQb4u3YdyL for <json@ietfa.amsl.com>; Tue, 24 May 2016 23:52:11 -0700 (PDT)
Received: from mail-wm0-x236.google.com (mail-wm0-x236.google.com [IPv6:2a00:1450:400c:c09::236]) (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 9328B12D644 for <json@ietf.org>; Tue, 24 May 2016 23:52:11 -0700 (PDT)
Received: by mail-wm0-x236.google.com with SMTP id a136so108346277wme.0 for <json@ietf.org>; Tue, 24 May 2016 23:52:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hxr-us.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-transfer-encoding; bh=OVcrt/ZkKk41h02uJq9lAqJKKAphx49rCWQNMfa+YEo=; b=bL/NRde3W92TWtYCL4JZxI01WNVonkTzkjPpgCiAl9fGJ9Cjq8uNDncNyimb9zf9XA uNfyaAxqnU6Gwlv/IqobgqfhdP15gMcaGzDh6TEd5JQ9LgT77nsGAJQsYIA9N7K2d+Jk c6EGhL9SwFPAeJIuAtGDTASpUFzSM36QP8jfimmCGzrOrcvzlFzh0r9hneN2MR5ir36f LVfwU0O0x0KKhg1G5YxMBAJXd6coGN1taXy5b79ig2iGvy6sAO3KlttlW+ktF8ZZv9+l kS0RKECQSVmGp7ctqT/RwBui0EuUVBpr1R8+N8J4i6hMDLLQLsYuqRzARjQ0Ss0avw/2 Litw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=OVcrt/ZkKk41h02uJq9lAqJKKAphx49rCWQNMfa+YEo=; b=DwfYekaLDpZF6uewa4qeMGpxsq9kAQ9RG9IvGcQewNIHxoYuuFae27E82y/QjE6G7s nZHUAZqWc9VrITM2yLDLWWL6Nc/FdN6uDqCpf9JTZzaAgrgUoOteC4F3hkcxi66RGqZv 0GkaDQ/eY8S0/6X9KdMH4Ja+kH/b9DqZzNHMbYO++j4Vn55D9noz3nQMQnr8x0QtqcSF MSapFvYzarujuCQuJ7Bpf9QizZ1CgKj+1NveuENm+kJp4oA4KSeVRwiy98ha/O1hk0ta guSOSn2QV02KM44fFEdnpDIa/AJ/GQ5bWQl8iUwIef6Gp1n9dH+6ONzfCIitVCYTnmmI WKkw==
X-Gm-Message-State: ALyK8tJoDBjD7wkqI/DcTytKG65WCVlr2UhvdA5IHtL5Z0RE5VknK2OOzHmrxzrZ1aA5Q3UVI8PSsgN3/ugGsA==
MIME-Version: 1.0
X-Received: by 10.28.212.8 with SMTP id l8mr1516559wmg.11.1464159129955; Tue, 24 May 2016 23:52:09 -0700 (PDT)
Received: by 10.194.153.39 with HTTP; Tue, 24 May 2016 23:52:09 -0700 (PDT)
X-Originating-IP: [94.127.55.205]
In-Reply-To: <CAHBU6iu_nYyUBS-8PAJ3zER=RNKfiV532vEOeOnfr5eXbPv8Tw@mail.gmail.com>
References: <CAHBU6ivd5JJ7Hx_JtNPSnW40jXzEF1Yr7=rwuZzGnFrRoMphbg@mail.gmail.com> <CANkuk-WppF4WgeZc5OX2-tozmCd+eYtPwFgmDtoiJHxwdSjDzw@mail.gmail.com> <CAHBU6iu_nYyUBS-8PAJ3zER=RNKfiV532vEOeOnfr5eXbPv8Tw@mail.gmail.com>
Date: Wed, 25 May 2016 02:52:09 -0400
Message-ID: <CAAQiQRdu2pixrXhuqqmWGjdab6_mCMVcPTKWQQu=Oh0n3MmW0g@mail.gmail.com>
From: Andrew Newton <andy@hxr.us>
To: Tim Bray <tbray@textuality.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/kjqYn-pv8VenThRePUZO9lUtuCE>
Cc: Austin William Wright <aaa@bzfx.net>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Another problematic JSON Schema use-case
X-BeenThere: json@ietf.org
X-Mailman-Version: 2.1.17
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, 25 May 2016 06:52:13 -0000

On Mon, May 23, 2016 at 11:54 PM, Tim Bray <tbray@textuality.com> wrote:
> Hmm, I have to excerpt one line here:
>
> On Mon, May 23, 2016 at 6:30 PM, Austin William Wright <aaa@bzfx.net> wrote:
>>
>>
>> In general, JSON Schema and many other schemas are designed to ensure
>> things are valid. They're not well engineered to help people fix things when
>> they're invalid.
>
>
> I find this troubling.  I expect modern compilers to give me highly
> actionable errors, with line numbers. Is the nature of JSON DSL’s and
> programming languages so deeply different that this is not a reasonable
> thing to ask a schema processor to do?

It's not too much to ask, but the problem may be with the JSON parser.
Many parsers ingest JSON and give back native data structures, which
is what makes JSON simple for most people. But a validator needs
context that a typical JSON parser does not provide.

>
> If so, then what are schemas for?  I’ve seen them as having two uses:
>
> 1. Specification aids
> 2. Debugging aids

While not typical, being malleable enough to aid the creation of
testing harnesses is a great third use.

>
> For #1, I see schemas as a poor second-best to clear human-readable
> description.

In my experience, many non-English readers greatly benefit from a
formal syntax. And depending on the complexity of the problem, prose
cannot strike the right balance between precision and TLDR.

> For #2, Schemas are appealingly declarative and presumably much more compact
> than the equivalent declarative code.  But if they can’t tell me what the
> problem is, why bother?  And furthermore, I’ve never thought validators
> could rely on schemas alone, because schemas can’t check semantic
> constraints (“is that a valid part number?”)

Certainly they are no replacement for application logic, but I don't
think anybody ever made that claim.


-andy