Re: [Json] A minimal examplotron-style JSON validation language.

Pete Cordell <petejson@codalogic.com> Wed, 29 May 2019 21:14 UTC

Return-Path: <petejson@codalogic.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 D703F1201E2 for <json@ietfa.amsl.com>; Wed, 29 May 2019 14:14:23 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.901
X-Spam-Level:
X-Spam-Status: No, score=-1.901 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, 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 7u1XXqxAl6uu for <json@ietfa.amsl.com>; Wed, 29 May 2019 14:14:21 -0700 (PDT)
Received: from ppsa-online.com (ppsa-online.com [217.199.162.192]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 013E41201E3 for <json@ietf.org>; Wed, 29 May 2019 14:14:20 -0700 (PDT)
Received: (qmail 11621 invoked from network); 29 May 2019 22:12:19 +0100
Received: from host86-174-116-175.range86-174.btcentralplus.com (HELO ?192.168.1.72?) (86.174.116.175) by lvps217-199-162-217.vps.webfusion.co.uk with ESMTPSA (AES128-SHA encrypted, authenticated); 29 May 2019 22:12:18 +0100
To: Nico Williams <nico@cryptonector.com>, John Cowan <cowan@ccil.org>
Cc: JSON WG <json@ietf.org>
References: <8224451C-F21B-41E5-A834-A9005050CB1F@tzi.org> <CAJK=1RjdYD6TZCNrw=H3d9ZLKLxZZOwVCOYYPwfbP+1ETDDz1Q@mail.gmail.com> <11CDA7F6-30BB-40E4-8926-2EDCBCFD785B@tzi.org> <CAHBU6iv8ZsFM5yco5gi+gcyU8d=u3bOSgiKaF6-hv-GARgNh9w@mail.gmail.com> <CAChr6SwNvG4Z7TKUxAVeH7HMVWiPsEBNb12K9zVkjaGt2_v0fw@mail.gmail.com> <CAHBU6ivTD_v7L-wQ+P9TmSfBY=5N+k-caaZ0TZhg6yZ_SWR_aA@mail.gmail.com> <CAChr6SzD8qdETafQKKU41BcYayTWf+C4GENd9FNzy5JYOv5jRQ@mail.gmail.com> <CAHBU6isx5aB94U-vn_t6GGoQ9W+ATDNYR6_+CtXgOhFho5Qh-g@mail.gmail.com> <20190529144005.GC11773@localhost> <CAD2gp_QELt-3=wqA1gRafNim8Y6fsxZ6hcQmTsoOxCSxU8eM1Q@mail.gmail.com> <20190529201716.GD11773@localhost>
From: Pete Cordell <petejson@codalogic.com>
Message-ID: <a5031f94-be72-4814-2147-45a9255d612b@codalogic.com>
Date: Wed, 29 May 2019 22:14:17 +0100
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1
MIME-Version: 1.0
In-Reply-To: <20190529201716.GD11773@localhost>
Content-Type: text/plain; charset="utf-8"; format="flowed"
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/prU_asBBrgf6oMKqACAI6LARQ5g>
Subject: Re: [Json] A minimal examplotron-style JSON validation 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: Wed, 29 May 2019 21:14:24 -0000

On 29/05/2019 21:17, Nico Williams wrote:
> On Wed, May 29, 2019 at 03:14:43PM -0400, John Cowan wrote:
>> Here is a very simple examplotron language:
>>
>> Sample document from json.org:
>>
>> {"menu": {
>>    "id": "file",
>>    "value": "File",
>>    "popup": {
>>      "menuitem": [
>>        {"value": "New", "onclick": "CreateNewDoc()"},
>>        {"value": "Open", "onclick": "OpenDoc()"},
>>        {"value": "Close", "onclick": "CloseDoc()"}
>>      ]
>>    }
>> }}
>>
 >...
> 
> My counter:
> 
>    top_level : choice(file_menu, edit_menu);
>    file_menu : object{"menu"->file_menu_contents};
>    edit_menu : object{"edit_menu"->edit_menu_contents};
>    file_menu_contents := object{
>      "id":"file", /* this means this must be present with this value */
>      "value":"File",
>      "popup": object { ... }
>    };

For a quick taste of JCR, see:

    http://json-content-rules.org/tutorial

For a more examplotron feel, JCR could define a #inferred-types 
directive so, for example, string values are treated as generic string 
rather than a specific string. e.g.:

#inferred-types
{
     "Image": {
         "Width":  800,
         "Height": 600,
         "Title":  "View from 15th Floor",
         "Thumbnail": {
             "Url":    "http://www.example.com/image/481989943",
             "Height": 125,
             "Width":  100
         },
     "Animated" : false,
     "IDs": [116, 943, 234, 38793]
     }
}

gets treated as:

{
     "Image": {
         "Width":  integer,
         "Height": integer,
         "Title":  string,
         "Thumbnail": {
             "Url":    string,
             "Height": integer,
             "Width":  integer
         },
     "Animated" : boolean,
     "IDs": [integer *]
     }
}

Pete.
-- 
---------------------------------------------------------------------
Pete Cordell
Codalogic Ltd
Read & write XML in C++, http://www.xml2cpp.com
---------------------------------------------------------------------