mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-24 05:46:05 +03:00
Update marshaling.go
This commit is contained in:
parent
0ed90e8351
commit
1e9692ec15
@ -60,25 +60,25 @@ func (l *StringMap) UnmarshalJSON(data []byte) error {
|
||||
|
||||
func (l *CustomFieldMap) UnmarshalJSON(data []byte) error {
|
||||
var i interface{}
|
||||
var m CustomFieldMap
|
||||
var items CustomFieldMap
|
||||
if err := json.Unmarshal(data, &i); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch e := i.(type) {
|
||||
case map[string]interface{}:
|
||||
m = make(CustomFieldMap, len(e))
|
||||
items = make(CustomFieldMap, len(e))
|
||||
for idx, val := range e {
|
||||
m[idx] = val
|
||||
items[idx] = val
|
||||
}
|
||||
case []interface{}:
|
||||
m = make(CustomFieldMap, len(e))
|
||||
items = make(CustomFieldMap, len(e))
|
||||
for idx, val := range e {
|
||||
m[strconv.Itoa(idx)] = val
|
||||
items[strconv.Itoa(idx)] = val
|
||||
}
|
||||
}
|
||||
|
||||
*l = m
|
||||
*l = items
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user