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

Carsten Bormann <cabo@tzi.org> Thu, 30 May 2019 09:36 UTC

Return-Path: <cabo@tzi.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 D627F1200F1 for <json@ietfa.amsl.com>; Thu, 30 May 2019 02:36:16 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.197
X-Spam-Level:
X-Spam-Status: No, score=-4.197 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=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 52GLoac4utM0 for <json@ietfa.amsl.com>; Thu, 30 May 2019 02:36:14 -0700 (PDT)
Received: from smtp.uni-bremen.de (gabriel-vm-2.zfn.uni-bremen.de [134.102.50.17]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id D65221200E0 for <json@ietf.org>; Thu, 30 May 2019 02:36:13 -0700 (PDT)
Received: from client-0039.vpn.uni-bremen.de (client-0039.vpn.uni-bremen.de [134.102.107.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.uni-bremen.de (Postfix) with ESMTPSA id 45F2Wv01HPz10RL; Thu, 30 May 2019 11:36:10 +0200 (CEST)
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\))
From: Carsten Bormann <cabo@tzi.org>
In-Reply-To: <CAJK=1RhEvgQUdzZnGSmnYYdaLyoDVceQ6gPmDziE2ufYLzYzbw@mail.gmail.com>
Date: Thu, 30 May 2019 11:36:10 +0200
Cc: JSON WG <json@ietf.org>
X-Mao-Original-Outgoing-Id: 580901723.450272-ddf368eaefbe7280668d6ef44a55192d
Content-Transfer-Encoding: quoted-printable
Message-Id: <D9AB7FE2-F465-4162-8FF3-4997857E91E7@tzi.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> <DD0F8B7F-3D78-43B0-9A92-9D02FFBDC516@tzi.org> <CAJK=1RhEvgQUdzZnGSmnYYdaLyoDVceQ6gPmDziE2ufYLzYzbw@mail.gmail.com>
To: Ulysse Carion <ulysse@segment.com>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/1CwwdeHSTAdHQYv-x-fhPnPkHsw>
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: Thu, 30 May 2019 09:36:17 -0000

Hi Ulysse,

your message catches me at the start of a long weekend (which seamlessly turns into an IAB workshop and more travel next week).  So I won’t have much time preparing anything in the next 10 days.

But most of the job of translating JSL into CDDL is already done in example form in

https://mailarchive.ietf.org/arch/msg/json/1WpdpfsXr3gEIdXb8OV0R_J-O4E

Adding enums is easy once there is a JSL side (one would have to decide between two conventions of doing them in CDDL) — can you propose that?
CDDL does have ways of specifying timestamps (both POSIX epoch-based numbers of seconds and RFC 3339 style; the independent tag 1001 is addressing further types of time such as TAI or GPS); which ones do we want?

Having a JSON data definition language like JSL that is both homoiconic (represented in JSON itself) and unable to fully describe its own structure might be considered ironic by some, but it is also a powerful statement of direction:  Not even starting to boil the ocean.

Grüße, Carsten


> On May 30, 2019, at 02:07, Ulysse Carion <ulysse@segment.com> wrote:
> 
> Hi Carsten,
> 
> Any thoughts on Tim Bray's suggestion? Regarding something akin to JSL (+ enums + timestamps), but perhaps built atop the foundations of CDDL?
> 
> - Ulysse
> 
> On Wed, May 29, 2019 at 2:15 PM Carsten Bormann <cabo@tzi.org> wrote:
> On May 29, 2019, at 22:17, Nico Williams <nico@cryptonector.com> wrote:
> > 
> >  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 { ... }
> >  };
> 
> While it is certainly enjoyable to design another language, I’m not sure why this should not be done in an ABNF-like syntax such as CDDL (which, by the way, is in AUTH48 and will soon be RFC 8610).  
> Keeping your names (even the snake case, where I’d be using kebab case):
> 
> top_level = file_menu / edit_menu
> file_menu = { menu: file_menu_contents }
> edit_menu = { edit_menu: edit_menu_contents }
> file_menu_contents = {
>   id: text    ; assuming here this is your examplotron content
>   value: text
>   popup: { }
> }
> edit_menu_contents = { }
> 
> I didn’t put in the ignore-unknown stuff; that would be 12 characters in CDDL unless you define something to make this shorter.
> 
> Put the above into a menus.cddl and try
> 
>   cddl menus.cddl g 10
> 
> you get 10 examples:
> 
> {"menu": {"id": "gray", "value": "commixt", "popup": {}}}
> {"menu": {"id": "proctoplasty", "value": "compunctious", "popup": {}}}
> {"menu": {"id": "taglike", "value": "valvulate", "popup": {}}}
> {"edit_menu": {}}
> {"menu": {"id": "uninundated", "value": "unworthily", "popup": {}}}
> {"edit_menu": {}}
> {"edit_menu": {}}
> {"menu": {"id": "Orangeist", "value": "imperialin", "popup": {}}}
> {"edit_menu": {}}
> {“edit_menu": {}}
> 
> This is a bit boring as there is only one choice and two non-singleton types.
> Sorry if I didn’t get the intent of your example right.
> 
> Grüße, Carsten
> 
> PS.: OK, with ignore-unknown:
> 
> top_level = file_menu / edit_menu
> file_menu = { menu: file_menu_contents _..._ }
> edit_menu = { edit_menu: edit_menu_contents _..._ }
> file_menu_contents = {
>   id: text    ; I'm assuming here this is your examplotron content
>   value: text
>   popup: { _..._ }
>   _..._
> }
> edit_menu_contents = { _..._ }
> 
> _..._ = ( * text => any )
> 
> ➔ 
> 
> {"menu": {"id": "fahlerz", "value": "unshocked", "popup": {"astrophotometry": "perdurance"}, "foolship": "pentacosane", "larrikin": "myoglobin"}}
> {"edit_menu": {"priggery": "cordaitean", "jackpudding": "righten", "unconfidence": "photolitho", "reviling": "ewe"}, "allophylic": "compound", "teacupful": "allergen"}
> {"menu": {"id": "amazement", "value": "condylomatous", "popup": {"cosounding": "share", "contribute": "gabblement", "gunpaper": "dividualism", "undersociety": "noration"}}}
> {"edit_menu": {"glareole": "clicket", "madling": "dizain"}, "scrimpily": "gypsywort", "neurofibrilla": "discolor"}
> {"edit_menu": {"unpermissive": "cockneity"}, "caudillism": "visa", "interloop": "anthracnose"}
> {"menu": {"id": "blankite", "value": "puffery", "popup": {"katuka": "Gnathostomata", "effeteness": "unspelt"}}, "Chaldaic": "extrafoliaceous", "trimesic": "dwindlement", "successful": "fluctuant", "nevadite": "aggradational"}
> {"menu": {"id": "acrostolion", "value": "devocalize", "popup": {}}, "cymation": "premanufacturer", "mysticete": "analyst", "ethnocentric": "Myrtales"}
> {"edit_menu": {"glycerolize": "blastoid", "undisputedness": "propheticly"}, "orchiotomy": "illiquidity"}
> {"menu": {"id": "tenebriously", "value": "guardo", "popup": {"abeigh": "fibrillar", "Sminthurus": "disnosed", "accessibility": "autem"}}}
> {"edit_menu": {"stableman": "erosional"}}
> 
> 
> 
> _______________________________________________
> json mailing list
> json@ietf.org
> https://www.ietf.org/mailman/listinfo/json