aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/encode.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/encode.go')
-rw-r--r--src/encoding/json/encode.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go
index 364e2724b7..69ac7e03c8 100644
--- a/src/encoding/json/encode.go
+++ b/src/encoding/json/encode.go
@@ -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