Update marshaling.go

This commit is contained in:
Pavel 2023-07-31 16:52:08 +03:00 committed by GitHub
parent 0ed90e8351
commit 1e9692ec15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,25 +60,25 @@ func (l *StringMap) UnmarshalJSON(data []byte) error {
func (l *CustomFieldMap) UnmarshalJSON(data []byte) error { func (l *CustomFieldMap) UnmarshalJSON(data []byte) error {
var i interface{} var i interface{}
var m CustomFieldMap var items CustomFieldMap
if err := json.Unmarshal(data, &i); err != nil { if err := json.Unmarshal(data, &i); err != nil {
return err return err
} }
switch e := i.(type) { switch e := i.(type) {
case map[string]interface{}: case map[string]interface{}:
m = make(CustomFieldMap, len(e)) items = make(CustomFieldMap, len(e))
for idx, val := range e { for idx, val := range e {
m[idx] = val items[idx] = val
} }
case []interface{}: case []interface{}:
m = make(CustomFieldMap, len(e)) items = make(CustomFieldMap, len(e))
for idx, val := range e { for idx, val := range e {
m[strconv.Itoa(idx)] = val items[strconv.Itoa(idx)] = val
} }
} }
*l = m *l = items
return nil return nil
} }