Tag
CBOR major type 6 wraps a single data item with a semantic tag number. Tags give meaning to otherwise untyped data: tag 0 = datetime string, tag 1 = epoch-based datetime, tag 2 = big integer, tag 32 = URI, tag 37 = UUID. Tags are optional – parsers that don't recognize a tag must still decode the wrapped item.
Encoding
Tags provide semantic annotations on top of CBOR's basic types. The tag number identifies the semantic, and the following data item is the tagged value. IANA maintains the CBOR Tags registry.
Important registered tags: Tag 0: Text string datetime (RFC 3339) Tag 1: Epoch-based datetime (integer or float seconds since 1970-01-01T00:00:00Z) Tag 2: Unsigned bignum (byte string) Tag 3: Negative bignum (byte string) Tag 21: Expected base64url encoding (for JSON interop) Tag 32: URI (text string) Tag 37: UUID (byte string, 16 bytes) Tag 55799: Self-described CBOR (marker for CBOR data)
Unrecognized tags must be ignored by decoders – the wrapped item is still decoded.
Examples
| Label | Hex | Value |
|---|---|---|
| Datetime string | c0 74 32 30 31 33 2d 30 33 2d 32 31 54 32 30 3a 30 34 3a 30 30 5a | tag(0) "2013-03-21T20:04:00Z" |
| Epoch time | c1 1a 51 4b 67 b0 | tag(1) 1363896240 (integer seconds) |
| UUID | d8 25 50 [16 bytes] | tag(37) 16-byte UUID |