Re: [Json] Schemas & so on

John Cowan <cowan@mercury.ccil.org> Tue, 03 May 2016 01:01 UTC

Return-Path: <cowan@ccil.org>
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 A281B12D693 for <json@ietfa.amsl.com>; Mon, 2 May 2016 18:01:16 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -3.597
X-Spam-Level:
X-Spam-Status: No, score=-3.597 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RP_MATCHES_RCVD=-0.996, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
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 P5sOpPEe5khb for <json@ietfa.amsl.com>; Mon, 2 May 2016 18:01:15 -0700 (PDT)
Received: from earth.ccil.org (earth.ccil.org [192.190.237.11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id E95F712B067 for <json@ietf.org>; Mon, 2 May 2016 18:01:14 -0700 (PDT)
Received: from cowan by earth.ccil.org with local (Exim 4.72) (envelope-from <cowan@ccil.org>) id 1axOi7-0008EL-J5; Mon, 02 May 2016 21:01:11 -0400
Date: Mon, 2 May 2016 21:01:11 -0400
From: John Cowan <cowan@mercury.ccil.org>
To: Mark Nottingham <mnot@mnot.net>
Message-ID: <20160503010109.GA17482@mercury.ccil.org>
References: <CAHBU6itCV9MXmALdKtE9-vjUPG6-6ZqdqzrmZkcEzSUysi3S-w@mail.gmail.com> <AC93811D-A16A-4527-B2EB-C6A9FC6D4F17@mnot.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <AC93811D-A16A-4527-B2EB-C6A9FC6D4F17@mnot.net>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <cowan@ccil.org>
Archived-At: <http://mailarchive.ietf.org/arch/msg/json/qDXc7mmLybkpn7c7laJL7WkvodM>
Cc: Tim Bray <tbray@textuality.com>, "json@ietf.org" <json@ietf.org>
Subject: Re: [Json] Schemas & so on
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: Tue, 03 May 2016 01:01:16 -0000

Mark Nottingham scripsit:

> It strikes me that it might be worth writing down what we think is good
> in such a beast, and what would be not-good. Getting agreement on that
> might be... interesting, but if we had such a document (or maybe just
> a wiki page), we'd be able to evaluate the current contenders, at least.

Here's what I think the bare necessities are for a schema language.
This is loosely based on FtanGram, the schema language for FtanML,
a markup language similar to XML and JSON.

1) A language for specifying the types of JSON items.  A type is a set of
JSON items.  If the root item matches the root type and each sub-item
recursively matches the subtype, then the JSON document is valid,
otherwise not.

2) The following primitive types:
2a) The set containing only JSON null.
2b) The set containing both JSON booleans.
2c) The set containing only JSON true.
2d) The set containing only JSON false.
2e) The set containing all JSON numbers.
2f) The set containing all JSON integers.
2g) The set containing all JSON strings.

3) The type of JSON numbers with a specified upper and/or lower bound
(inclusive or exclusive).

4) The type of JSON integers with a specified upper and/or lower bound
(inclusive or exclusive).

5) The type of JSON strings that match a specified regular expression.

6) The type of all JSON arrays.

7) The type of JSON arrays that match a specified regular expression
over types which match the elements of the array.  The regular expression
operators are sequence, choice, and bounded and unbounded repetition.

8) The type of all JSON objects.

9) The type of JSON objects with specified keys, with the types of the
values corresponding to those keys.  Keys may be required or optional.
In addition, a way to specify whether other keys are allowed or forbidden.

10) The type of all JSON items.

11) The ability to name a type and refer to it by name.

12) The ability to define type libraries and import types from them.

Comments?

-- 
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
Awk!" sed Grep. "A fscking python is perloining my Ruby; let me bash
    him with a Cshell!  Vi didn't I mount it on a troff?" --Francis Turner