Skip to content

Instantly share code, notes, and snippets.

@theory
Last active May 16, 2025 16:53
Show Gist options
  • Save theory/ef667af1c725240e6e30d525786d58e6 to your computer and use it in GitHub Desktop.
Save theory/ef667af1c725240e6e30d525786d58e6 to your computer and use it in GitHub Desktop.

JSON Number String Tag for CBOR

This document specifies a tag for representing JSON numbers as strings in Concise Binary Object Representation (CBOR)[1]. This allows the preservation of numeric values treated as strings rather than the I-JSON (RFC 7493[2]) limits on numbers.

Semantics

Tag 284 can be applied to a text string (major type 3) or byte string (major type 2) to indicate that the string represents a JSON number in string form as defined by RFC 8259[3]’s grammar for numbers, shown here in a simplified form:

number = [ "-" ] int [ frac ] [ exp ]
int = "0" / ( digit1-9 *DIGIT )
frac = "." 1*DIGIT
exp = "E" [ "-" / "+" ] 1*DIGIT
digit1-9 = %x31-39         ; 1-9
DIGIT = %x30-39            ; 0-9

References

[1] T. Bray, Ed. "The I-JSON Message Format". RFC 7493, March 2015.
[2] C. Bormann, and P. Hoffman. "Concise Binary Object Representation (CBOR)". RFC 8949, December 2020.
[3] T. Bray, Ed. "The JavaScript Object Notation (JSON) Data Interchange Format". RFC 8259, December 2017.

Author

David Wheeler [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment