Skip to main content
6

Tag

0xc0 – 0xdbRFC 8949

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

Initial byte: 0b110_XXXXX. Argument = tag number. Followed by one data item.

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

LabelHexValue
Datetime stringc0 74 32 30 31 33 2d 30 33 2d 32 31 54 32 30 3a 30 34 3a 30 30 5atag(0) "2013-03-21T20:04:00Z"
Epoch timec1 1a 51 4b 67 b0tag(1) 1363896240 (integer seconds)
UUIDd8 25 50 [16 bytes]tag(37) 16-byte UUID

See Also