@@ -51,6 +51,62 @@ func embeddedType() {
51
51
json .Marshal (& Foo {}) // want "the given struct should be annotated with the `json` tag"
52
52
}
53
53
54
+ func nestedArrayType () {
55
+ type Bar struct {
56
+ NoTag string
57
+ }
58
+ type Foo struct {
59
+ Bars [5 ]Bar `json:"bars"`
60
+ }
61
+ var foo Foo
62
+ json .Marshal (foo ) // want "the given struct should be annotated with the `json` tag"
63
+ json .Marshal (& foo ) // want "the given struct should be annotated with the `json` tag"
64
+ json .Marshal (Foo {}) // want "the given struct should be annotated with the `json` tag"
65
+ json .Marshal (& Foo {}) // want "the given struct should be annotated with the `json` tag"
66
+ }
67
+
68
+ func nestedSliceType () {
69
+ type Bar struct {
70
+ NoTag string
71
+ }
72
+ type Foo struct {
73
+ Bars []Bar `json:"bars"`
74
+ }
75
+ var foo Foo
76
+ json .Marshal (foo ) // want "the given struct should be annotated with the `json` tag"
77
+ json .Marshal (& foo ) // want "the given struct should be annotated with the `json` tag"
78
+ json .Marshal (Foo {}) // want "the given struct should be annotated with the `json` tag"
79
+ json .Marshal (& Foo {}) // want "the given struct should be annotated with the `json` tag"
80
+ }
81
+
82
+ func nestedMapType () {
83
+ type Bar struct {
84
+ NoTag string
85
+ }
86
+ type Foo struct {
87
+ Bars map [string ]Bar `json:"bars"`
88
+ }
89
+ var foo Foo
90
+ json .Marshal (foo ) // want "the given struct should be annotated with the `json` tag"
91
+ json .Marshal (& foo ) // want "the given struct should be annotated with the `json` tag"
92
+ json .Marshal (Foo {}) // want "the given struct should be annotated with the `json` tag"
93
+ json .Marshal (& Foo {}) // want "the given struct should be annotated with the `json` tag"
94
+ }
95
+
96
+ func nestedComplexType () {
97
+ type Bar struct {
98
+ NoTag string
99
+ }
100
+ type Foo struct {
101
+ Bars * * [][]map [string ][][5 ][5 ]map [string ]* Bar `json:"bars"`
102
+ }
103
+ var foo Foo
104
+ json .Marshal (foo ) // want "the given struct should be annotated with the `json` tag"
105
+ json .Marshal (& foo ) // want "the given struct should be annotated with the `json` tag"
106
+ json .Marshal (Foo {}) // want "the given struct should be annotated with the `json` tag"
107
+ json .Marshal (& Foo {}) // want "the given struct should be annotated with the `json` tag"
108
+ }
109
+
54
110
func recursiveType () {
55
111
// should not cause panic; see issue #16.
56
112
type Foo struct {
0 commit comments