// UnmarshalJSON sets *args fields with given data.
5248
func (args *FilterCriteria) UnmarshalJSON(data []byte) error {
	type input struct {
		BlockHash *common.Hash     `json:"blockHash"`
		FromBlock *rpc.BlockNumber `json:"fromBlock"`
		ToBlock   *rpc.BlockNumber `json:"toBlock"`
		Addresses interface{}      `json:"address"`
		Topics    []interface{}    `json:"topics"`
	}

	var raw input
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}

	if raw.BlockHash != nil {
		if raw.FromBlock != nil || raw.ToBlock != nil {
			// BlockHash is mutually exclusive with FromBlock/ToBlock criteria
			return fmt.Errorf("cannot specify both BlockHash and FromBlock/ToBlock, choose one or the other")
		}
		args.BlockHash = raw.BlockHash
	} else {
		if raw.FromBlock != nil {
			args.FromBlock = big.NewInt(raw.FromBlock.Int64())
		}

		if raw.ToBlock != nil {
			args.ToBlock = big.NewInt(raw.ToBlock.Int64())
		}
	}

	args.Addresses = []common.Address{}

	if raw.Addresses != nil {
		// raw.Address can contain a single address or an array of addresses
		switch rawAddr := raw.Addresses.(type) {
		case []interface{}:
			for i, addr := range rawAddr {
				if strAddr, ok := addr.(string); ok {
					addr, err := decodeAddress(strAddr)
					if err != nil {
						return fmt.Errorf("invalid address at index %d: %v", i, err)
					}
					args.Addresses = append(args.Addresses, addr)
				} else {
					return fmt.Errorf("non-string address at index %d", i)
				}
			}
		case string:
			addr, err := decodeAddress(rawAddr)
			if err != nil {
				return fmt.Errorf("invalid address: %v", err)
			}
			args.Addresses = []common.Address{addr}
		default:
			return errors.New("invalid addresses in query")
		}
	}

	// topics is an array consisting of strings and/or arrays of strings.
	// JSON null values are converted to common.Hash{} and ignored by the filter manager.
	if len(raw.Topics) > 0 {
		args.Topics = make([][]common.Hash, len(raw.Topics))
		for i, t := range raw.Topics {
			switch topic := t.(type) {
			case nil:
				// ignore topic when matching logs

			case string:
				// match specific topic
				top, err := decodeTopic(topic)
				if err != nil {
					return err
				}
				args.Topics[i] = []common.Hash{top}

			case []interface{}:
				// or case e.g. [null, "topic0", "topic1"]
				for _, rawTopic := range topic {
					if rawTopic == nil {
						// null component, match all
						args.Topics[i] = nil
						break
					}
					if topic, ok := rawTopic.(string); ok {
						parsed, err := decodeTopic(topic)
						if err != nil {
							return err
						}
						args.Topics[i] = append(args.Topics[i], parsed)
					} else {
						return fmt.Errorf("invalid topic(s)")
					}
				}
			default:
				return fmt.Errorf("invalid topic(s)")
			}
		}
	}

	return nil
}
74776
func (s *JSONMapItem) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{Data: data}
	s.UnmarshalEasyJSON(&l)
	return l.Error()
}
1162891
func (u *Uint64) UnmarshalJSON(data []byte) error {
	if isNull(data) {
		u.Valid = false
		return nil
	}
	if err := json.Unmarshal(data, &u.Uint64); err != nil {
		return err
	}
	u.Valid = true
	return nil
}
705730
func (j *JSONText) UnmarshalJSON(data []byte) error {
	if j == nil {
		return errors.New("JSONText: UnmarshalJSON on nil pointer")
	}
	*j = append((*j)[0:0], data...)
	return nil
}
782120
func (s *StreamName) UnmarshalJSON(data []byte) error {
	v := ""
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	if err := StreamName(v).Validate(); err != nil {
		return err
	}
	*s = StreamName(v)
	return nil
}
592022
func (self *StructFieldDef) UnmarshalJSON(b []byte) error {
	var m rawStructFieldDef
	err := json.Unmarshal(b, &m)
	if err == nil {
		o := StructFieldDef(m)
		*self = o
		err = self.Validate()
	}
	return err
}
546150
func (o *NatGateway) UnmarshalJSON(data []byte) error {
	var jsonName string
	if err := json.Unmarshal(data, &jsonName); err == nil {
		o.Name = &jsonName
		return nil
	}

	var r realNatGateway
	if err := json.Unmarshal(data, &r); err != nil {
		return err
	}
	*o = NatGateway(r)
	return nil
}
1014834
func (v *bulkIndexRequestCommandOp) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson9de0fcbfDecodeGithubComOlivereElastic(&r, v)
	return r.Error()
}
948159
func (r *Raw) UnmarshalJSON(data []byte) error {
	if r == nil {
		return errors.New("Raw: UnmarshalJSON on nil pointer")
	}
	*r = append((*r)[0:0], data...)
	return nil
}
360076
func (t *JSONTime) UnmarshalJSON(data []byte) error {
	ts, err := strconv.ParseInt(string(data), 10, 64)
	if err != nil {
		return err
	}
	*t = JSONTime(time.Unix(0, ts*1000))
	return nil
}
12440
func (v *Complained) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson692db02bDecodeGithubComMailgunMailgunGoEvents15(&r, v)
	return r.Error()
}
329235
func (v *bulkIndexRequestCommand) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson9de0fcbfDecodeGithubComOlivereElastic1(&r, v)
	return r.Error()
}
282199
func (r *rawBase64) UnmarshalJSON(b []byte) error {
	if len(b) > 1 && b[0] == '"' && b[len(b)-1] == '"' {
		b = b[1 : len(b)-1]
	}
	*r = rawBase64(b)
	return nil
}
677034
func (v *Annotation) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson72863a49DecodeGithubComSignalfxGolibTraceFormat3(&r, v)
	return r.Error()
}
735403
func (j *Json) UnmarshalJSON(p []byte) error {
	return json.Unmarshal(p, &j.data)
}
648100
func (e *goof) UnmarshalJSON(data []byte) error {

	umd := map[string]interface{}{}
	if err := json.Unmarshal(data, &umd); err != nil {
		return err
	}

	uge, err := unmarshalMap(umd)
	if err != nil {
		return err
	}

	e.msg = uge.msg
	e.data = uge.data

	return nil
}
978038
func (v *ClientInfo) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonCce3d1beDecodeGithubComMailgunMailgunGoEvents8(&r, v)
	return r.Error()
}