Skip to content

ecorm/cbor-tag-text-key-map

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

cbor-tag-text-key-map

This document describes a CBOR tag for maps having text-only keys.

Tag value: 275

Data item: Map (major type 5)

Semantics: Map contains only keys that are of type Text String (major type 3)

Rationale

When converting from CBOR to JSON, a sensible way to handle CBOR maps with non-text keys would be to output them as arrays of pairs. A Javascript decoder consuming the JSON conversion may then interpret the array of pairs as a Map.

When the input map contains only text keys, it may be preferrable to output a JSON Object instead of an array of pairs, so that a Javascript decoder may interpret it directly as an Object.

The problem with this approach is that a stream-based CBOR-to-JSON converter cannot determine a priori if the input CBOR map contains only text keys. Once it has begun encoding an output Object, it cannot change the output representation once it encounters a non-text key in the input CBOR map.

With this tag, it's possible for a stream-based CBOR-to-JSON converter to determine a priori if an input CBOR map contains only text keys, and thus encode it directly to a JSON Object without having to first process the entire input map.

About

CBOR tag for maps having text-only keys

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published