Subject: [Cbor] Using CDDL with JSON

From: Carsten Bormann <[email-masked]>
Date: Sat, 6 May 2017 15:34:58 +0200

The use of CDDL with JSON, as in RFC 8007, always was pretty much obvious, but never has been described in detail.

I have written a section on a subset of the prelude that applies to JSON, also discussing some of the finer points of using CDDL with JSON.  I’d love to hear from people who have experience with this particular topic.

The section is not yet submitted as an Internet-Draft, so please see:

https://cbor-wg.github.io/cddl/#rfc.appendix.E.1

Grüße, Carsten

---

From: "Paul Hoffman" <[email-masked]>
Date: Sat, 06 May 2017 08:33:12 -0700

On 6 May 2017, at 6:34, Carsten Bormann wrote:

> The use of CDDL with JSON, as in RFC 8007, always was pretty much 
> obvious, but never has been described in detail.
>
> I have written a section on a subset of the prelude that applies to 
> JSON, also discussing some of the finer points of using CDDL with 
> JSON.  I’d love to hear from people who have experience with this 
> particular topic.
>

This seems like a good addition, useful to both the CBOR and JSON 
communities. It needs to be scrutinized by the JSONites, of course.

The document is now getting a bit messy with JSON being used in a few 
disparate places. A thought is to pull them all out, create a short 
second document for just JSON, and point to it in the introduction to 
this document. If we do want to leave the JSON examples and definition 
stuff in this document, it might be better to make them one appendix, 
and discuss that in the Introduction.

--Paul Hoffman

---

From: Carsten Bormann <[email-masked]>
Date: Sun, 7 May 2017 00:15:27 +0200

On May 6, 2017, at 17:33, Paul Hoffman <[email-masked]> wrote:
> 
> The document is now getting a bit messy with JSON being used in a few disparate places.

I don’t find that many places “using” JSON.

There is an example based on RFC 7071, which is a JSON format.  I think this is illustrative; there are not that many examples around that are as simple as RFC 7071 (and which become so convincingly complicated by trying to tell them in English).  Of course, we should now also point at RFC 8007 for another example.

Then there is an example taken from JSON content rules (JCR).  JCR is another definition technique that could theoretically be extended to also cover all of CBOR; the example here is mostly useful for people who have looked at JCR.  Maybe we can pull out the whole of section 4 (with the JCR example, RFC 7071, and a small maybe not so useful example about describing fruit that actually does make use of two CBOR-beyond-JSON features) and push it into an appendix; this would save 6.5 pages in the main body.

> A thought is to pull them all out, create a short second document for just JSON, and point to it in the introduction to this document. If we do want to leave the JSON examples and definition stuff in this document, it might be better to make them one appendix, and discuss that in the Introduction.

So I seem to tend to the latter.  (The really JSON-specific discussion I just wrote already is in an appendix, albeit a different one, because it is not an example.)

Grüße, Carsten

---

From: "Paul Hoffman" <[email-masked]>
Date: Sat, 06 May 2017 15:35:09 -0700

On 6 May 2017, at 15:15, Carsten Bormann wrote:

>> disparate places.
> There is an example based on RFC 7071, which is a JSON format.  I 
> think this is illustrative; there are not that many examples around 
> that are as simple as RFC 7071 (and which become so convincingly 
> complicated by trying to tell them in English).  Of course, we should 
> now also point at RFC 8007 for another example.

This example sure feels like "here is a good thing with CDDL". If it is 
illustrative, then it says "you can do this".

> Then there is an example taken from JSON content rules (JCR).  JCR is 
> another definition technique that could theoretically be extended to 
> also cover all of CBOR; the example here is mostly useful for people 
> who have looked at JCR.  Maybe we can pull out the whole of section 4 
> (with the JCR example, RFC 7071, and a small maybe not so useful 
> example about describing fruit that actually does make use of two 
> CBOR-beyond-JSON features) and push it into an appendix; this would 
> save 6.5 pages in the main body.

Yep. I'm not worried about making the body shorter; I want the JSON 
stuff by itself so that it is clearer to readers.

>
>> A thought is to pull them all out, create a short second document for 
>> just JSON, and point to it in the introduction to this document. If 
>> we do want to leave the JSON examples and definition stuff in this 
>> document, it might be better to make them one appendix, and discuss 
>> that in the Introduction.
>
> So I seem to tend to the latter.  (The really JSON-specific discussion 
> I just wrote already is in an appendix, albeit a different one, 
> because it is not an example.)

Sounds fine.

--Paul Hoffman

---

From: Christophe Lohr <[email-masked]>
Date: Tue, 9 May 2017 13:47:38 +0200

Hello,
I apologize for my naïve question that may have been dealt with already.

Is there any relationship between CDDL an Json-Schemas?
http://json-schema.org/documentation.html

This seems to share almost the same purpose, isn't it?
(with another context (cbor in place of json), other notations, some
specificities, etc.)

Best regards
Christophe

---

From: Carsten Bormann <[email-masked]>
Date: Tue, 9 May 2017 14:33:53 +0200

Hi Christophe,

Thank you for your question.

> http://json-schema.org/documentation.html

There are several approaches to define JSON data.
JSON Schema is one of them, JSON Content Rules (JCR) is another.
I don’t think many people expect that one description technique will be used by everyone.
CDDL is focused to be useful in defining the structure protocol messages based on CBOR’s data model, which is a superset of JSON’s, so it can be used for JSON as well.  A number of IETF documents have used CDDL for defining JSON data, e.g., RFC 8007.

> This seems to share almost the same purpose, isn't it?

The approaches behind these description techniques are very different, even if they have some overlaps in expressive coverage.
CDDL is basically a production system (tree grammar), with a syntax derived from ABNF and some ideas inspired by Relax-NG Compact and JSON Content Rules.
I’m not going to try to describe how that relates to other approaches, but I can say that I’m quite satisfied with how useful CDDL has been in defining a number of CBOR- and JSON-based protocols I have been involved with.

Grüße, Carsten