In Concise Data Definition Language (CDDL) [
RFC 8610], CBOR Sequences are already supported as contents of byte strings using the
.cborseq control operator (
Section 3.8.4 of
RFC 8610) by employing an array as the controller type:
my-embedded-cbor-seq = bytes .cborseq my-array
my-array = [* my-element]
my-element = my-foo / my-bar
Currently, CDDL does not provide for unadorned CBOR Sequences as a top-level subject of a specification. For now, the suggestion is to use an array for the top-level rule, as is used for the
.cborseq control operator, and add English text that explains that the specification is really about a CBOR Sequence with the elements of the array:
; This defines an array, the elements of which are to be used
; in a CBOR Sequence:
my-sequence = [* my-element]
my-element = my-foo / my-bar
(Future versions of CDDL may provide a notation for top-level CBOR Sequences, e.g., by using a group as the top-level rule in a CDDL specification.)
CBOR diagnostic notation (see
Section 6 of
RFC 7049) or extended diagnostic notation (
Appendix G of
RFC 8610) also does not provide for unadorned CBOR Sequences at this time (the latter does provide for CBOR Sequences embedded in a byte string as per
Appendix G.3 of
RFC 8610).
In a similar spirit to the recommendation for CDDL above, this specification recommends enclosing the CBOR data items in an array. In a more informal setting, where the boundaries within which the notation is used are obvious, it is also possible to leave off the outer brackets for this array, as shown in these two examples:
Note that it is somewhat difficult to discuss zero-length CBOR Sequences in the latter form.
In certain applications, being able to efficiently skip an element without the need for decoding its substructure, or efficiently fanning out elements to multi-threaded decoding processes, is of the utmost importance. For these applications, byte strings (which carry length information in bytes) containing embedded CBOR can be used as the elements of a CBOR Sequence:
; This defines an array of CBOR byte strings, the elements of which
; are to be used in a CBOR Sequence:
my-sequence = [* my-element]
my-element = bytes .cbor my-element-structure
my-element-structure = my-foo / my-bar
Within limits, this may also enable recovering from elements that internally are not well formed; the limitation is that the sequence of byte strings does need to be well formed as such.