Allow leading zero with exponents; e.g., "0e1". #201
Allow leading zero with exponents; e.g., "0e1". #201
Conversation
Fixes one of the two issues brought up in #198.
("-0", 0), | ||
("0e1", 0), | ||
("-0e20", 0), | ||
("0.1e1", 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe check with negative exponent and zero exponent, as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also toss in one with uppercase E to check we handle that variant spelling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe more fun with leading zeroes, too, like 0001E0001
for 10
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on neg/zero exponent and uppercase E
. Leading zeros are not allowed in JSON, and we already have a unit test to confirm they're rejected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a leading zero is admitted for the exponent, though. The number
production uses int
restricted to be zero or non-zero and then whatever digits, but exp
is just "at least one digit" in its numeric part, so leading zeroes are legit there.
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
https://tools.ietf.org/html/rfc7159 section 6 (page 6)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 711f3a7
👍 LGTM |
Fixes one of the two issues brought up in #198.