@@ -318,7 +318,7 @@ func parseFloat(b []byte) (float64, error) {
|
||||
if cleaned[0] == '+' || cleaned[0] == '-' {
|
||||
start = 1
|
||||
}
|
||||
if cleaned[start] == '0' && isDigit(cleaned[start+1]) {
|
||||
if cleaned[start] == '0' && len(cleaned) > start+1 && isDigit(cleaned[start+1]) {
|
||||
return 0, unstable.NewParserError(b, "float integer part cannot have leading zeroes")
|
||||
}
|
||||
|
||||
|
||||
@@ -240,6 +240,11 @@ func TestUnmarshal_Floats(t *testing.T) {
|
||||
input: `0E0`,
|
||||
expected: 0.0,
|
||||
},
|
||||
{
|
||||
desc: "float zero without decimals",
|
||||
input: `0`,
|
||||
expected: 0.0,
|
||||
},
|
||||
{
|
||||
desc: "float fractional with exponent",
|
||||
input: `6.626e-34`,
|
||||
|
||||
Reference in New Issue
Block a user