zcbor
A low-footprint CBOR library for microcontrollers, paired with a Python schema tool that validates YAML, JSON, or CBOR data and can generate C code for encoding and decoding it.
zcbor is a low-footprint CBOR (Concise Binary Object Representation) library written in C, compatible with C++, tailored for use on microcontrollers, and usable on its own independent of its companion Python tooling. Its schema language is CDDL (Concise Data Definition Language, an IETF standard), which lets you describe detailed, advanced schemas for validating and converting data.
The Python script and module can validate a YAML, JSON, or CBOR file against a CDDL schema, convert between those formats, for example turning a validated YAML file into CBOR for transmission, decode and validate incoming CBOR data into human-readable YAML or JSON, and create a read-only representation of validated data through named tuples derived from the schema's field names; it shares its internal representation with other common Python YAML, JSON, and CBOR libraries. The code-generation part of the tool produces C code from the schema that performs CBOR encoding and decoding using the C library while validating data against every rule in the schema, intended for optimized or constrained environments. The project ships samples showing both the standalone C library and the generated-code approach, and its tests run under Zephyr.