Subject: [Cbor] Re: Tag for Number as String?
From: Carsten Bormann <[email-masked]>
To: "David E. Wheeler" <[email-masked]>
Cc: [email-masked]
Date: Mon, 28 Apr 2025 20:55:40 +0200
List-Id: "Concise Binary Object Representation (CBOR)" <cbor.ietf.org>

On 28. Apr 2025, at 20:30, David E. Wheeler <[email-masked]> wrote:
> 
> Ah, nice. But text, not a byte string, eh? That that there’s a difference for ascii, which I’m pretty sure is all that would be in the representation of a JSON number.

Both text and byte strings work here (and you could simply allow both).
Limiting this to byte strings is surprising, though, because most text turns up as text strings.

RFC 8259 says:

      number = [ minus ] int [ frac ] [ exp ]
      decimal-point = %x2E       ; .
      digit1-9 = %x31-39         ; 1-9
      e = %x65 / %x45            ; e E
      exp = e [ minus / plus ] 1*DIGIT
      frac = decimal-point 1*DIGIT
      int = zero / ( digit1-9 *DIGIT )
      minus = %x2D               ; -
      plus = %x2B                ; +
      zero = %x30                ; 0

Not sure whether the " key was broken on the author’s laptop; in readable form this would be:

      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

Grüße, Carsten