File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -100,13 +100,11 @@ func ConvertNonPrimitive[T mapstrOrMap](m T) {
100
100
if ref .Kind () == reflect .Slice || ref .Kind () == reflect .Array {
101
101
s := make ([]any , ref .Len ())
102
102
for i := 0 ; i < ref .Len (); i ++ {
103
- elem := ref .Index (i )
104
- if elem .Kind () == reflect .Map && elem .Type ().Key ().Kind () == reflect .String && elem .Type ().Elem ().Kind () == reflect .Interface {
105
- if m , ok := elem .Interface ().(map [string ]any ); ok {
106
- ConvertNonPrimitive (m )
107
- }
103
+ elem := ref .Index (i ).Interface ()
104
+ if m , ok := elem .(map [string ]any ); ok {
105
+ ConvertNonPrimitive (m )
108
106
}
109
- s [i ] = elem . Interface ()
107
+ s [i ] = elem
110
108
}
111
109
m [key ] = s
112
110
break // we figured out the type, so we don't need the unknown type case
Original file line number Diff line number Diff line change @@ -281,14 +281,18 @@ func TestFromMapstrWithNestedData(t *testing.T) {
281
281
"bool_slice" : []bool {false , true },
282
282
"inner" : []mapstr.M {
283
283
{
284
- "inner_int" : 42 ,
284
+ "inner_int" : 42 ,
285
+ "inner_map_slice" : [1 ]any {nil },
285
286
"inner_slice" : []map [string ]any { // slice -> slice
286
287
{"string" : "string" },
287
288
{"number" : 12.3 },
288
289
},
289
290
},
290
291
{
291
292
"inner_int" : 43 ,
293
+ "inner_map_slice" : []any {
294
+ map [string ]any {"string" : "string3" },
295
+ },
292
296
"inner_slice" : [2 ]map [string ]any { // array -> slice
293
297
{"string" : "string2" },
294
298
{"number" : 12.4 },
@@ -303,14 +307,18 @@ func TestFromMapstrWithNestedData(t *testing.T) {
303
307
"bool_slice" : []any {false , true },
304
308
"inner" : []any {
305
309
map [string ]any {
306
- "inner_int" : 42 ,
310
+ "inner_int" : 42 ,
311
+ "inner_map_slice" : []any {nil },
307
312
"inner_slice" : []any {
308
313
map [string ]any {"string" : "string" },
309
314
map [string ]any {"number" : 12.3 },
310
315
},
311
316
},
312
317
map [string ]any {
313
318
"inner_int" : 43 ,
319
+ "inner_map_slice" : []any {
320
+ map [string ]any {"string" : "string3" },
321
+ },
314
322
"inner_slice" : []any {
315
323
map [string ]any {"string" : "string2" },
316
324
map [string ]any {"number" : 12.4 },
You can’t perform that action at this time.
0 commit comments