// WithUnmarshalHookFunction provides an option to pass Custom Decode Hook Func
// for unmarshaling
425251
func WithUnmarshalHookFunction(hookFunction mapstructure.DecodeHookFunc) UnmarshalOption {
	return func(o *unmarshalOpts) {
		o.hooks = append(o.hooks, hookFunction)
	}
}
1188998
func (ua *Uint64Array) UnmarshalJSON(data []byte) error {
	if isNull(data) {
		ua.Valid = false
		return nil
	}
	if data == nil {
		ua.Uint64Array, ua.Valid = nil, false
		return nil
	}
	ua.Valid = true
	return json.Unmarshal(data, &ua.Uint64Array)
}
962969
func (d Decoder) Unmarshal(data []byte, f Format) (interface{}, error) {
	if data == nil {
		switch f {
		case CSV:
			return make([][]string, 0), nil
		default:
			return make(map[string]interface{}), nil
		}

	}
	var v interface{}
	err := d.unmarshal(data, f, &v)

	return v, err
}
319004
func (v *InputAnnotation) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson3b0ebf6aDecodeGithubComSignalfxGatewayProtocolSignalfxFormat5(&r, v)
	return r.Error()
}
842496
func (v *LargePayload) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonCfe4e5f0DecodeGithubComFrancoispqtGojayBenchmarks(&r, v)
	return r.Error()
}
628442
func UnmarshalJSON(bs []byte, x interface{}) (err error) {
	buf := bytes.NewBuffer(bs)
	decoder := NewJSONDecoder(buf)
	return decoder.Decode(x)
}
988953
func (o *ValidUntilOption) UnmarshalJSON(data []byte) error {
	if string(data) == "null" {
		o.value = time.Time{}
		return nil
	}
	return json.Unmarshal(data, &o.value)
}
613021
func (x *StringExpr) UnmarshalJSON(data []byte) error {
	var v string
	err := json.Unmarshal(data, &v)
	if err == nil {
		x.Func = nil
		x.Literal = v
		return nil
	}

	// Perhaps we have a serialized function call (like `{"Ref": "Foo"}`)
	// so we'll try to unmarshal it with UnmarshalFunc. Not all Funcs also
	// implement StringFunc, so we have to make sure that the referenced
	// function actually works in the boolean context
	funcCall, err2 := unmarshalFunc(data)
	if err2 == nil {
		stringFunc, ok := funcCall.(Stringable)
		if ok {
			x.Func = stringFunc
			return nil
		}
	} else if unknownFunctionErr, ok := err2.(UnknownFunctionError); ok {
		return unknownFunctionErr
	}

	// Return the original error trying to unmarshal the literal expression,
	// which will be the most expressive.
	return err
}
954486
func (v *Uint64) UnmarshalJSON(data []byte) error {
	l := jlexer.Lexer{Data: data}
	v.UnmarshalEasyJSON(&l)
	return l.Error()
}
398164
func (c *FileLink) UnmarshalJSON(data []byte) error {
	if id, ok := ParseID(data); ok {
		c.ID = id
		return nil
	}

	type fileLink FileLink
	var v fileLink
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}

	*c = FileLink(v)
	return nil
}
1003437
func (x *StringListExpr) UnmarshalJSON(data []byte) error {
	var v []*StringExpr
	err := json.Unmarshal(data, &v)
	if err == nil {
		x.Func = nil
		x.Literal = v
		return nil
	}

	// Perhaps we have a serialized function call (like `{"Ref": "Foo"}`)
	// so we'll try to unmarshal it with UnmarshalFunc. Not all Funcs also
	// implement StringListFunc, so we have to make sure that the referenced
	// function actually works in the boolean context
	funcCall, err2 := unmarshalFunc(data)
	if err2 == nil {
		stringFunc, ok := funcCall.(StringListFunc)
		if ok {
			x.Func = stringFunc
			return nil
		}

		// Possible that it's a Fn::GetAtt instance?
		getAttrFunc, ok := funcCall.(GetAttFunc)
		if ok {
			x.Func = StringList(getAttrFunc)
			return nil
		}
		return fmt.Errorf("%#v is not a StringListFunc", funcCall)
	}

	// Perhaps we have a single item, like "foo" which
	// occurs occasionally.
	var v2 StringExpr
	err3 := json.Unmarshal(data, &v2)
	if err3 == nil {
		x.Func = nil
		x.Literal = []*StringExpr{&v2}
		return nil
	}

	// Return the original error trying to unmarshal the literal expression,
	// which will be the most expressive.
	return err
}
1121301
func (f *SelectFunc) UnmarshalJSON(data []byte) error {
	v := struct {
		FnSelect []json.RawMessage `json:"Fn::Select"`
	}{}
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	if len(v.FnSelect) != 2 {
		return &json.UnsupportedValueError{Str: string(data)}
	}
	// Possible that the second arg is another template, in which case
	// we need to check for that...Example:
	/*
		"Fn::Select": [
				0,
				{
						"Fn::GetAtt": [
								"ApplicationLoadBalancer",
								"SecurityGroups"
						]
				}
		]
	*/
	var positionSelector interface{}
	if err := json.Unmarshal(v.FnSelect[0], &positionSelector); err != nil {
		return err
	}
	// If it's an integer or boolean, there's an issue
	switch positionSelector.(type) {
	case bool, int:
		return &json.UnsupportedValueError{Str: fmt.Sprintf("%v", positionSelector)}
	}
	f.Selector = fmt.Sprintf("%v", positionSelector)

	// What about the second one?
	if err := json.Unmarshal(v.FnSelect[1], &f.Items); err != nil {
		return err
	}

	return nil
}
1248478
func (pTypeDef *TimestampTest) UnmarshalJSON(b []byte) error {
	var r rawTimestampTest
	err := json.Unmarshal(b, &r)
	if err == nil {
		o := TimestampTest(r)
		*pTypeDef = o
		err = pTypeDef.Validate()
	}
	return err
}
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
}
934024
func (v *bulkDeleteRequestCommand) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson8092efb6DecodeGithubComOlivereElastic1(&r, v)
	return r.Error()
}
958241
func (v *bulkUpdateRequestCommandOp) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson1ed00e60DecodeGithubComOlivereElastic(&r, v)
	return r.Error()
}
911882
func UnmarshalDecoderToCallback(in SimpleDecoder, f interface{}) error {
	valueFunc := reflect.ValueOf(f)
	t := reflect.TypeOf(f)
	if t.NumIn() != 1 {
		return fmt.Errorf("the given function must have exactly one parameter")
	}
	cerr := make(chan error)
	c := reflect.MakeChan(reflect.ChanOf(reflect.BothDir, t.In(0)), 0)
	go func() {
		cerr <- UnmarshalDecoderToChan(in, c.Interface())
	}()
	for {
		select {
		case err := <-cerr:
			return err
		default:
		}
		v, notClosed := c.Recv()
		if !notClosed || v.Interface() == nil {
			break
		}
		valueFunc.Call([]reflect.Value{v})
	}
	return nil
}