Concise Data Definition Language (CDDL): Additional Control Operators for the Conversion and Processing of Text
Extracted elements (19)
A .jsonseq operator for JSON text sequences (RFC 7464) is not provided because no use case for inclusion in CDDL was known at the time of writing; it could be added in a future registration.
.base10 is defined to match only decimal integers without leading zeros (regex 0|-?[1-9][0-9]*). This opinionated choice increases usability by preventing ambiguous representations.
Sloppy variants are defined only for base64 (not base32 or base32hex) because no legacy use of sloppy base32(hex) was known at the time of writing. Base45 is strongly specified to disallow sloppy forms.
The base-encoding operators are intentionally opinionated: base64url with padding and base32(hex) with padding are excluded because experience shows these combinations only occur in error. Adding 'c' in .b64c ensures a deliberate choice for classic base64.
The .join operator is hard to validate in the general case (requiring full parser functionality), so its use is recommended to be limited to simple arrangements with constant 'marker' elements separating variable elements with no adjacent variable elements without intervening constants.
The .json operator provides no way to constrain blank space or serialization order in JSON output; such restrictions (e.g., canonical JSON) are deferred to potential future control operators.
For .join, byte sequences in individual array elements need not individually be valid UTF-8; only the final concatenated result must be valid UTF-8 if the target is a text string. This contrasts with RFC 8949 Section 3.2.3.
JSON has known interoperability problems (RFC 7493). Section 2 of RFC 7493 provides requirements that must be followed when using the .json control operator with CDDL's generic data model, particularly regarding numbers outside JSON's interoperable range.
The strict base64 control operators (.b64u, .b64c) differ from CDDL's 'b64' literal prefix notation: the control operators only match characters from their specific alphabet, while the 'b64' literal prefix accepts characters from either alphabet.
It is RECOMMENDED that .join implementations provide full coverage at least for the marker-based subset, where constant array elements serve as guideposts to isolate variable elements that need further CDDL-level validation.
Length modifiers (paragraph 7 of Section 7.23.6.1 of the C standard) MUST NOT be included in the format string of the .printf control operator.
The 'p' and 'n' conversion specifiers MUST NOT be included in the format string of the .printf control operator.
Ten control operators for byte-string-to-text conversion are defined: .b64u (Base64url, no padding), .b64u-sloppy, .b64c (Base64 classic, padding), .b64c-sloppy, .b32 (Base32, no padding), .h32 (Base32 Extended Hex, no padding), .hex (Base16, either case), .hexlc (lower case), .hexuc (upper case), and .b45 (Base45). Each takes a text target and a bytes controller.
The .base10 control operator models text strings carrying a decimal integer (no leading zeros), matching the regular expression 0|-?[1-9][0-9]*. It is typed text target with int controller and is useful for YANG-JSON uint64/int64 formats.
The .join control operator builds a text or byte string by concatenating elements of a controller array. The result type matches the kind of the first element; if the result is a text string, it must be valid UTF-8.
The .json control operator models text strings that embed a complete JSON value. It uses the JSON-to-CBOR conversion rules from Section 6.2 of RFC 8949 (STD94), analogous to the .cbor operator in RFC 8610.
The .printf control operator models text strings produced by C-style printf formatting. Its controller is an array whose first element is a format string and remaining elements are data items matching the conversion specifications.
IANA has registered 14 new control operators (.b64u, .b64u-sloppy, .b64c, .b64c-sloppy, .b45, .b32, .h32, .hex, .hexlc, .hexuc, .base10, .printf, .json, .join) into the 'CDDL Control Operators' registry at IANA.cddl.
The security considerations from RFC 8610 Section 5 apply to all control operators defined in this document. For the base-encoding operators in Section 2.1, the security considerations from RFC 4648 Section 12 also apply.