diff options
| author | Russ Cox <rsc@golang.org> | 2015-11-25 11:34:41 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2015-12-04 16:18:57 +0000 |
| commit | c4135dac630d093e01f95ea651d7d4330f616cfb (patch) | |
| tree | 5f8c5024977912245678b403745b4f5eccd3082f /src/encoding/json/encode.go | |
| parent | e8cc083ede9120c70b9d38b603ba07b3e62bd95d (diff) | |
| download | go-c4135dac630d093e01f95ea651d7d4330f616cfb.tar.xz | |
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>
Diffstat (limited to 'src/encoding/json/encode.go')
| -rw-r--r-- | src/encoding/json/encode.go | 5 |
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 |
