]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/json: clarify the map's key type for Unmarshal
authorJes Cok <xigua67damn@gmail.com>
Tue, 18 Jun 2024 15:43:21 +0000 (23:43 +0800)
committerGopher Robot <gobot@golang.org>
Fri, 21 Jun 2024 18:42:18 +0000 (18:42 +0000)
While here, also fix doc link for encoding.TextMarshaler.

Fixes #67495

Change-Id: Ia2a674c5c35b5a849ce8f5eef3d34d165b3195b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/593335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/encoding/json/decode.go
src/encoding/json/encode.go

index efceecdf82b04dcc764891d43834969791d842ef..f8205704e38b7ffa86b21816ae96ef4374b1184c 100644 (file)
@@ -73,8 +73,7 @@ import (
 // use. If the map is nil, Unmarshal allocates a new map. Otherwise Unmarshal
 // reuses the existing map, keeping existing entries. Unmarshal then stores
 // key-value pairs from the JSON object into the map. The map's key type must
-// either be any string type, an integer, implement [json.Unmarshaler], or
-// implement [encoding.TextUnmarshaler].
+// either be any string type, an integer, or implement [encoding.TextUnmarshaler].
 //
 // If the JSON-encoded data contain a syntax error, Unmarshal returns a [SyntaxError].
 //
index cb28feb279f6c0d5bb23e056b024f9473a188f46..7bee1a6805f4dc2d836a9afe1f8cb28b0930b325 100644 (file)
@@ -141,7 +141,7 @@ import (
 // are sorted and used as JSON object keys by applying the following rules,
 // subject to the UTF-8 coercion described for string values above:
 //   - keys of any string type are used directly
-//   - [encoding.TextMarshalers] are marshaled
+//   - keys that implement [encoding.TextMarshaler] are marshaled
 //   - integer keys are converted to strings
 //
 // Pointer values encode as the value pointed to.