Re: [Json] Schemas & so on

John Cowan <> Tue, 03 May 2016 01:01 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id A281B12D693 for <>; Mon, 2 May 2016 18:01:16 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: -3.597
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 ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id P5sOpPEe5khb for <>; Mon, 2 May 2016 18:01:15 -0700 (PDT)
Received: from ( []) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by (Postfix) with ESMTPS id E95F712B067 for <>; Mon, 2 May 2016 18:01:14 -0700 (PDT)
Received: from cowan by with local (Exim 4.72) (envelope-from <>) id 1axOi7-0008EL-J5; Mon, 02 May 2016 21:01:11 -0400
Date: Mon, 2 May 2016 21:01:11 -0400
From: John Cowan <>
To: Mark Nottingham <>
Message-ID: <>
References: <> <>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <>
User-Agent: Mutt/1.5.20 (2009-06-14)
Sender: John Cowan <>
Archived-At: <>
Cc: Tim Bray <>, "" <>
Subject: Re: [Json] Schemas & so on
X-Mailman-Version: 2.1.17
Precedence: list
List-Id: "JavaScript Object Notation \(JSON\) WG mailing list" <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-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.


John Cowan
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