mirror of
https://github.com/foomo/sesamy-go.git
synced 2025-10-16 12:35:43 +00:00
19 lines
371 B
Go
19 lines
371 B
Go
package sesamy
|
|
|
|
import (
|
|
"github.com/mitchellh/mapstructure"
|
|
)
|
|
|
|
func Decode(input any, output any) error {
|
|
decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
|
Result: output,
|
|
TagName: "json",
|
|
WeaklyTypedInput: true,
|
|
IgnoreUntaggedFields: true,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return decoder.Decode(input)
|
|
}
|