mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-27 15:10:30 +00:00
* Kucoin: Rename WsSpotTicker => WsSnapshot * Kucoin: Replace kucoinNumber => types.Number * Okcoin: Convert to types.Number * Gateio: Convert to types.Number * Okx: Convert to types.Number
27 lines
667 B
Go
27 lines
667 B
Go
package kucoin
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// UnmarshalJSON valid data to SubAccountsResponse of return nil if the data is empty list.
|
|
// this is added to handle the empty list returned when there are no accounts.
|
|
func (a *SubAccountsResponse) UnmarshalJSON(data []byte) error {
|
|
var result interface{}
|
|
err := json.Unmarshal(data, &result)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var ok bool
|
|
if a, ok = result.(*SubAccountsResponse); ok {
|
|
if a == nil {
|
|
return errNoValidResponseFromServer
|
|
}
|
|
return nil
|
|
} else if _, ok := result.([]interface{}); ok {
|
|
return nil
|
|
}
|
|
return fmt.Errorf("%w can not unmarshal to SubAccountsResponse", errMalformedData)
|
|
}
|