func (d *Delegations) UnmarshalJSON(data []byte) error {
	if string(data) == "[]" || string(data) == "null" {
		return nil
	}
	var raw []Delegation
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	*d = raw
	return nil
}
UnmarshalJSON ensures that we get [] for empty arrays
package types
import (
	"encoding/json"
)
type QueryResponse queryResponseImpl
type queryResponseImpl struct {
	Ok  []byte `json:"ok,omitempty"`
	Err string `json:"error,omitempty"`
}
func (q QueryResponse) MarshalJSON() ([]byte, error) {
	if len(q.Ok) == 0 && len(q.Err) == 0 {
		return []byte(`{"ok":""}`), nil
	}
	return json.Marshal(queryResponseImpl(q))
}
type Querier interface {
	Query(request QueryRequest, gasLimit uint64) ([]byte, error)
	GasConsumed() uint64
}
func RustQuery(querier Querier, binRequest []byte, gasLimit uint64) QuerierResult {
	var request QueryRequest
	err := json.Unmarshal(binRequest, &request)
	if err != nil {
		return QuerierResult{
			Err: &SystemError{
				InvalidRequest: &InvalidRequest{
					Err:     err.Error(),
					Request: binRequest,
				},
			},
		}
	}
	bz, err := querier.Query(request, gasLimit)
	return ToQuerierResult(bz, err)
}
type QuerierResult struct {
	Ok  *QueryResponse `json:"ok,omitempty"`
	Err *SystemError   `json:"error,omitempty"`
}
func ToQuerierResult(response []byte, err error) QuerierResult {
	if err == nil {
		return QuerierResult{
			Ok: &QueryResponse{
				Ok: response,
			},
		}
	}
	syserr := ToSystemError(err)
	if syserr != nil {
		return QuerierResult{
			Err: syserr,
		}
	}
	return QuerierResult{
		Ok: &QueryResponse{
			Err: err.Error(),
		},
	}
}
type QueryRequest struct {
	Bank     *BankQuery      `json:"bank,omitempty"`
	Custom   json.RawMessage `json:"custom,omitempty"`
	IBC      *IBCQuery       `json:"ibc,omitempty"`
	Staking  *StakingQuery   `json:"staking,omitempty"`
	Stargate *StargateQuery  `json:"stargate,omitempty"`
	Wasm     *WasmQuery      `json:"wasm,omitempty"`
}
type BankQuery struct {
	Balance     *BalanceQuery     `json:"balance,omitempty"`
	AllBalances *AllBalancesQuery `json:"all_balances,omitempty"`
}
type BalanceQuery struct {
	Address string `json:"address"`
	Denom   string `json:"denom"`
}
type BalanceResponse struct {
	Amount Coin `json:"amount"`
}
type AllBalancesQuery struct {
	Address string `json:"address"`
}
type AllBalancesResponse struct {
	Amount Coins `json:"amount"`
}
type IBCQuery struct {
	PortID       *PortIDQuery       `json:"port_id,omitempty"`
	ListChannels *ListChannelsQuery `json:"list_channels,omitempty"`
	Channel      *ChannelQuery      `json:"channel,omitempty"`
}
type PortIDQuery struct{}
type PortIDResponse struct {
	PortID string `json:"port_id"`
}
type ListChannelsQuery struct {
	PortID string `json:"port_id,omitempty"`
}
type ListChannelsResponse struct {
	Channels IBCChannels `json:"channels"`
}
type IBCChannels []IBCChannel
func (e IBCChannels) MarshalJSON() ([]byte, error) {
	if len(e) == 0 {
		return []byte("[]"), nil
	}
	var raw []IBCChannel = e
	return json.Marshal(raw)
}
func (e *IBCChannels) UnmarshalJSON(data []byte) error {
	if string(data) == "[]" || string(data) == "null" {
		return nil
	}
	var raw []IBCChannel
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	*e = raw
	return nil
}
type IBCEndpoints []IBCEndpoint
func (e IBCEndpoints) MarshalJSON() ([]byte, error) {
	if len(e) == 0 {
		return []byte("[]"), nil
	}
	var raw []IBCEndpoint = e
	return json.Marshal(raw)
}
func (e *IBCEndpoints) UnmarshalJSON(data []byte) error {
	if string(data) == "[]" || string(data) == "null" {
		return nil
	}
	var raw []IBCEndpoint
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	*e = raw
	return nil
}
type ChannelQuery struct {
	PortID    string `json:"port_id,omitempty"`
	ChannelID string `json:"channel_id"`
}
type ChannelResponse struct {
	Channel *IBCChannel `json:"channel,omitempty"`
}
type StakingQuery struct {
	AllValidators  *AllValidatorsQuery  `json:"all_validators,omitempty"`
	Validator      *ValidatorQuery      `json:"validator,omitempty"`
	AllDelegations *AllDelegationsQuery `json:"all_delegations,omitempty"`
	Delegation     *DelegationQuery     `json:"delegation,omitempty"`
	BondedDenom    *struct{}            `json:"bonded_denom,omitempty"`
}
type AllValidatorsQuery struct{}
type AllValidatorsResponse struct {
	Validators Validators `json:"validators"`
}
type Validators []Validator
func (v Validators) MarshalJSON() ([]byte, error) {
	if len(v) == 0 {
		return []byte("[]"), nil
	}
	var raw []Validator = v
	return json.Marshal(raw)
}
func (v *Validators) UnmarshalJSON(data []byte) error {
	if string(data) == "[]" || string(data) == "null" {
		return nil
	}
	var raw []Validator
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	*v = raw
	return nil
}
type ValidatorQuery struct {
	Address string `json:"address"`
}
type ValidatorResponse struct {
	Validator *Validator `json:"validator"`  
}
type Validator struct {
	Address string `json:"address"`
	Commission string `json:"commission"`
	MaxCommission string `json:"max_commission"`
	MaxChangeRate string `json:"max_change_rate"`
}
type AllDelegationsQuery struct {
	Delegator string `json:"delegator"`
}
type DelegationQuery struct {
	Delegator string `json:"delegator"`
	Validator string `json:"validator"`
}
type AllDelegationsResponse struct {
	Delegations Delegations `json:"delegations"`
}
type Delegations []Delegation
func (d Delegations) MarshalJSON() ([]byte, error) {
	if len(d) == 0 {
		return []byte("[]"), nil
	}
	var raw []Delegation = d
	return json.Marshal(raw)
}