12345678910111213141516171819202122232425 |
- package map2struct
- import (
- "github.com/mitchellh/mapstructure"
- )
- func WeakDecode(input, output interface{}) error {
- config := &mapstructure.DecoderConfig{
- Metadata: nil,
- Result: output,
- WeaklyTypedInput: true,
- DecodeHook: mapstructure.ComposeDecodeHookFunc(
- ToDecimalHookFunc(), ToTimeHookFunc(), ToNullableStringHookFunc(),
- ToTimePtrHookFunc(),
- ),
- TagName: "json",
- }
- decoder, err := mapstructure.NewDecoder(config)
- if err != nil {
- return err
- }
- return decoder.Decode(input)
- }
|