NordicSemiconductor / zcbor

Low footprint C/C++ CBOR library and Python tool providing code generation from CDDL descriptions.
Apache License 2.0
114 stars 34 forks source link

Expecting either one or the other map key #364

Closed mkschreder closed 1 year ago

mkschreder commented 1 year ago

I would like to specify in the schema that I expect either one or the other map key but not both. Something like this:

person_choice = {
    "name": tstr,
    "age" uint / "is_expired": bool
}

I'm getting parse error.

Is this possible?

oyvindronningstad commented 1 year ago

Two things:

person_choice = {
    "name": tstr,
    ("age": uint) / ("is_expired": bool)
}