Re: [Json] JSON Schema Language

Carsten Bormann <cabo@tzi.org> Tue, 07 May 2019 16:41 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 85C3F120196 for <json@ietfa.amsl.com>; Tue, 7 May 2019 09:41:09 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -4.199
X-Spam-Level:
X-Spam-Status: No, score=-4.199 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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 bbSf_I1FG-vu for <json@ietfa.amsl.com>; Tue, 7 May 2019 09:41:07 -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 23FC112018B for <json@ietf.org>; Tue, 7 May 2019 09:41:07 -0700 (PDT)
Received: from [192.168.217.106] (p54A6CC75.dip0.t-ipconnect.de [84.166.204.117]) (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 44z52m5zVcz10H0; Tue, 7 May 2019 18:41:04 +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: <cfcdd163-36d0-8b98-5f34-84c3e5e774ad@codalogic.com>
Date: Tue, 07 May 2019 18:41:04 +0200
Cc: Tim Bray <tbray@textuality.com>, Ulysse Carion <ulysse@segment.com>, json@ietf.org
X-Mao-Original-Outgoing-Id: 578940062.159153-213330db636ddd43e68b4554133f0e40
Content-Transfer-Encoding: quoted-printable
Message-Id: <211E9F29-901A-4D5F-A958-C760AD2A49C4@tzi.org>
References: <CAJK=1RjV1uv0eOdtFZ8cKn-FfCwCiGP5r2hOz1UamiM6YV4H1A@mail.gmail.com> <CAHBU6itE8kub1qtdRoW8BqxaOmzMv=vUo1aDeuAr3HX141NUGg@mail.gmail.com> <cfcdd163-36d0-8b98-5f34-84c3e5e774ad@codalogic.com>
To: Pete Cordell <petejson@codalogic.com>
X-Mailer: Apple Mail (2.3445.9.1)
Archived-At: <https://mailarchive.ietf.org/arch/msg/json/1WpdpfsXr3gEIdXb8OV0R_J-O4E>
Subject: Re: [Json] JSON Schema 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: Tue, 07 May 2019 16:41:10 -0000

On May 7, 2019, at 18:15, Pete Cordell <petejson@codalogic.com> wrote:
> 
> long winded

Here are a few examples from the JSL draft with the CDDL equivalents (behind the “===“; note that CDDL supports both text and byte strings, so uses “text” for text strings):

   { “type”: “number” }     
   ===
   number

   {                        
     “elements”: {
       “type”: “number”
     }
   }
   ===
   [* number]

   ([] signifies an array, * signifies zero or more)

   {                           
     "properties": {
       "a": { "type": "string" },
       "b": { "type": "string" }
     },
     "optionalProperties": {
       "c": { "type": "string" },
       "d": { "type": "string" }
     }
   }
   ===
   { a: text, b: text, ? c: text, ? d: text }

   ({} signifies an object, ? signifies zero or one)

   {
     "values": {
       "type": "number"
     }
   }
   ===
   { * text => number }

   (=> can be used to separate type names for key and value)

   {
     "discriminator": {
       "tag": "version",
       "mapping": {
         "v1": {
           "properties": {
             "a": { "type": "number" }
           }
         },
         "v2": {
           "properties": {
             "a": { "type": "string" }
           }
         }
       }
     }
   }
   ===
   { tag: “v1”, a: number } / { tag: “v2”, a: text }

   (/ signifies a choice)

Noise in specifications hurts:
https://www.iab.org/wp-content/IAB-uploads/2016/03/Noise-in-specifications-hurts.pdf

Grüße, Carsten