mirror of
https://github.com/golang/go.git
synced 2025-11-08 20:51:02 +00:00
encoding/json: streamline, unexport valid Number checking
Followup to CL 12250. For #10281. Change-Id: If25d9cac92f10327bb355f2d11b00c625b464661 Reviewed-on: https://go-review.googlesource.com/17199 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
e8cc083ede
commit
c4135dac63
3 changed files with 44 additions and 101 deletions
|
|
@ -534,8 +534,9 @@ func stringEncoder(e *encodeState, v reflect.Value, quoted bool) {
|
|||
// we keep compatibility so check validity after this.
|
||||
if numStr == "" {
|
||||
numStr = "0" // Number's zero-val
|
||||
} else if !Number(numStr).IsValid() {
|
||||
e.error(fmt.Errorf("json: invalid number literal, trying to marshal %s", v.String()))
|
||||
}
|
||||
if !isValidNumber(numStr) {
|
||||
e.error(fmt.Errorf("json: invalid number literal %q", numStr))
|
||||
}
|
||||
e.WriteString(numStr)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue