mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-21 20:36:03 +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 {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user