aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/decode_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding/json/decode_test.go')
-rw-r--r--src/encoding/json/decode_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go
index fc546bf2a7..27ceee471a 100644
--- a/src/encoding/json/decode_test.go
+++ b/src/encoding/json/decode_test.go
@@ -195,6 +195,11 @@ type embed struct {
Q int
}
+type Issue21357 struct {
+ *embed
+ R int
+}
+
type Loop struct {
Loop1 int `json:",omitempty"`
Loop2 int `json:",omitempty"`
@@ -866,6 +871,20 @@ var unmarshalTests = []unmarshalTest{
err: fmt.Errorf("json: unknown field \"extra\""),
disallowUnknownFields: true,
},
+
+ // Issue 21357.
+ // Ignore any embedded fields that are pointers to unexported structs.
+ {
+ in: `{"Q":1,"R":2}`,
+ ptr: new(Issue21357),
+ out: Issue21357{R: 2},
+ },
+ {
+ in: `{"Q":1,"R":2}`,
+ ptr: new(Issue21357),
+ err: fmt.Errorf("json: unknown field \"Q\""),
+ disallowUnknownFields: true,
+ },
}
func TestMarshal(t *testing.T) {