Class CborParser

All Implemented Interfaces:
CborMetaProvider, ArrayRecordReadable, RecordReadable, TokenReadable
Direct Known Subclasses:
CborParser.Base64, CborParser.SpacedHex

Parses CBOR streams (RFC 8949) into POJO models.
Media types
Handles Content-Type types: application/cbor
Description

CBOR-to-Java type mapping:

  • CBOR map (major type 5) → bean or Map
  • CBOR array (major type 4) → Collection or Java array
  • CBOR text string (major type 3) → String; coerced to types parseable from string
  • CBOR unsigned/negative integer (major types 0/1) → Integer or Long
  • CBOR float (major type 7, 0xFA/0xFB) → Float or Double
  • CBOR half-precision float (major type 7, 0xF9) → Float (converted)
  • CBOR boolean (major type 7, 0xF4/0xF5) → Boolean
  • CBOR null (major type 7, 0xF6) → null
  • CBOR byte string (major type 2) → byte[]
  • CBOR semantic tag (major type 6) → tag ignored; tagged value parsed normally
Round-trip notes:
  • Integers (major types 0/1) surface by target type: a BigInteger field carries the full unsigned-64-bit magnitude; any other numeric type keeps the raw 64-bit bits as a long.
  • BigInteger / BigDecimal round-trip losslessly (big integers decode from native CBOR integers or, beyond ±2^64, from their decimal string; BigDecimal decodes from its decimal string).
  • Indefinite-length CBOR (RFC 8949 §3.2) is supported: arrays, maps, and chunked text/byte strings all decode.
  • Semantic tags are read and discarded on the databind path; tag number does not affect parsed type. Enable nativeMode to surface tags/simple values on the TokenReader cursor.
Notes:
  • This class is thread safe and reusable.
See Also: