123456789101112131415161718192021222324 |
- 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(),
- ),
- TagName: "json",
- }
- decoder, err := mapstructure.NewDecoder(config)
- if err != nil {
- return err
- }
- return decoder.Decode(input)
- }
|