Skip to content

Commit 50dc922

Browse files
stainless-app[bot]batuhan
authored andcommitted
fix: fix for encoding arrays with any type items
1 parent aeba089 commit 50dc922

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

internal/apiform/encoder.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ func (e *encoder) encodeArray(key string, val reflect.Value, writer *multipart.W
101101
var values []string
102102
for i := 0; i < val.Len(); i++ {
103103
item := val.Index(i)
104+
if (item.Kind() == reflect.Pointer || item.Kind() == reflect.Interface) && item.IsNil() {
105+
// Null values are sent as an empty string
106+
values = append(values, "")
107+
continue
108+
}
109+
// If item is an interface, reduce it to the concrete type
110+
if item.Kind() == reflect.Interface {
111+
item = item.Elem()
112+
}
104113
var strValue string
105114
switch item.Kind() {
106115
case reflect.String:

0 commit comments

Comments
 (0)