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

Phillip Hallam-Baker <ietf@hallambaker.com> Wed, 25 May 2016 01:26 UTC

Return-Path: <hallam@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 C2C4A12D6AE for <json@ietfa.amsl.com>; Tue, 24 May 2016 18:26:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.4
X-Spam-Level:
X-Spam-Status: No, score=-2.4 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.198, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_PASS=-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 QCy3xAZ5vWzc for <json@ietfa.amsl.com>; Tue, 24 May 2016 18:26:08 -0700 (PDT)
Received: from mail-qk0-x22c.google.com (mail-qk0-x22c.google.com [IPv6:2607:f8b0:400d:c09::22c]) (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 2037812D521 for <json@ietf.org>; Tue, 24 May 2016 18:26:08 -0700 (PDT)
Received: by mail-qk0-x22c.google.com with SMTP id y126so24705916qke.1 for <json@ietf.org>; Tue, 24 May 2016 18:26:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc; bh=AGy3NbeTt5lyUSgBZfIH2n9O/nP6e3VI347bYLQ1MDM=; b=orPK76VR43p30L5j/gFHrFv9VVw1dMnb0kOKXGk/eaYoRFP95Bjg3eQnWDaLSM8qH7 nl9cKjoF/vxIpk2xjTKwdaRtPEhYF3OHwZbw3f46c3fyEVKPtE2RE0uqA5i52jRUYtc6 qk9KWjGB2v/+a/lrCyoV8tnASUlNnX3H9p/BRGdynt3Gp18E49tJ39z8tTwiJdvtNwzF pUw0CiQ5lcpZQ7NoJRLpYRimiLov1sKJGD9iObD90jkxRBsj3ImQJ926a2r4DmgX1mRb DLMMapVBq+cC3eMr5qQQIJywRKpUpyHtUSYfGSLENtKap8fl0cZENE5Xo/57G8GVYF+A i9sA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc; bh=AGy3NbeTt5lyUSgBZfIH2n9O/nP6e3VI347bYLQ1MDM=; b=MbJBPIY5JdGdFmAW61XpKRj0y2fiX9UaHLuixAAh23dEzwv+/bZBArTQdo2ltMUETf lBUPXzjPkJL+BP/jEKkv/Z0eRpsWaBqcUZIhPoJHEuND3eJwsDkqRMlDuZp7ny5eiGnF ayZqIl6vrlzlGcPTGgjZizVSBHyB9rMrHLXskD0KoCuQiQelGuZ3vnVTnFti2X8yzUI0 79ibCOPMre3wcrG7JlYwICiViuBkonIqKxjqIijEEWv9sbIc8MPi6A9LVSSxFYayjIbN Hi3jULd3kembEKhLy7JSSavH/KjMYJpEN8t1gArwDgVDyA974iHbZknAAc3UN32wjRjV f8RQ==
X-Gm-Message-State: ALyK8tIFN5owi+oLDrAwN3MCAh9imcC73VvJM4hvrVSY/HS2oROcLBcMj34ZbX6qy94E2HqpyeznOZ7/XPs8RA==
MIME-Version: 1.0
X-Received: by 10.55.114.71 with SMTP id n68mr1181242qkc.37.1464139567168; Tue, 24 May 2016 18:26:07 -0700 (PDT)
Sender: hallam@gmail.com
Received: by 10.55.25.105 with HTTP; Tue, 24 May 2016 18:26:06 -0700 (PDT)
In-Reply-To: <CANkuk-Ufuzd4SZjV9-096J7yTSBt1XsRkra-dteXdgSMH8=QPA@mail.gmail.com>
References: <CAHBU6ivd5JJ7Hx_JtNPSnW40jXzEF1Yr7=rwuZzGnFrRoMphbg@mail.gmail.com> <CANkuk-WppF4WgeZc5OX2-tozmCd+eYtPwFgmDtoiJHxwdSjDzw@mail.gmail.com> <CAHBU6iu_nYyUBS-8PAJ3zER=RNKfiV532vEOeOnfr5eXbPv8Tw@mail.gmail.com> <CANkuk-Ufuzd4SZjV9-096J7yTSBt1XsRkra-dteXdgSMH8=QPA@mail.gmail.com>
Date: Tue, 24 May 2016 21:26:06 -0400
X-Google-Sender-Auth: Q-Nyzsng4z1ntaPPSqxirGwZKVg
Message-ID: <CAMm+LwgwjHeGDSpq5C8QkTO2oQ15NikBPqN2vYX-mAEVNSw9Rw@mail.gmail.com>
From: Phillip Hallam-Baker <ietf@hallambaker.com>
To: Austin William Wright <aaa@bzfx.net>
Content-Type: multipart/alternative; boundary="001a114fef8acd80b80533a08eb7"
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/33QIY6F6HUN5jbKWZ4YOZ0iTjok>
Cc: Tim Bray <tbray@textuality.com>, "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 01:26:10 -0000

On Tue, May 24, 2016 at 9:07 PM, Austin William Wright <aaa@bzfx.net> wrote:

> I also use them as specification aids, I think JSON Hyperschema is a great
> tool to make JSON APIs become RESTful (because it's self-documenting).
>
> I also use them for validation and sanity checking, like an assert() call:
> It's not something that should ever trip, but it's there in case the
> impossible happens (but that would never happen, right?).
>
> I agree with your opinion it's troubling, though. Unfortunately it's hard
> to strike a balance between making something that's easy to compose and
> easy to read, versus something that's expressive and gives you exactly the
> right error message.
>
> I'd love to talk how to fix this problem, though!
>
> It seems like this problem is closely tied with automatic UI generation.
> How would I design a form to enter data of the kind that you're expecting?
> Three separate forms? A master drop-down that automatically changes the
> remaining fields and automatically populates the "Type" one? Move the
> "Type" drop-down first, and change all the other fields if it changes? What
> if I want to change the type of an entity from Vegetable to Plant? It seems
> if we can answer these questions, we would also tackle your validation
> errors problem for free.
>


Funny you should say that. This past couple of weeks I have resurrected the
GUI generator I built for X-Windows before working on the Web. [The new
version targets GTK as primary and will probably do Windows Forms and HTML
in due course]

Yes, there are similarities between the problems. In both cases you have an
abstract model and a presentation of that model, a View for the UI and a
serialization for JSON. Yes, if one had the problem of producing both, you
could share a lot of code. But not so much as you might expect.

A GUI is a Model-View-Controller app and unlike the problem of
serializing/deserializing JSON, you have to do a lot of validation on the
inputs. In particular you need to be able to validate a dialog box when the
user hits 'Accept' and tell them where they went wrong. You also need to be
able to support 'cancel'.

In short, it ends up as a very much more involved problem if you are going
to do it right. XML is as complex as it is because it supports features
that allow text editors to validate input as people type. And JSON is
simpler because it does not support those features. And if you try to turn
JSON into XML you will probably end up with something almost as complex.