DecodeMapStruct with time.Time and Iso8601Time support
(input map[string]interface{}, result interface{}, zeroFields bool)
| 106 | |
| 107 | // DecodeMapStruct with time.Time and Iso8601Time support |
| 108 | func DecodeMapStruct(input map[string]interface{}, result interface{}, zeroFields bool) errors.Error { |
| 109 | result = models.UnwrapObject(result) |
| 110 | decoder, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ |
| 111 | ZeroFields: zeroFields, |
| 112 | DecodeHook: mapstructure.ComposeDecodeHookFunc(defaultCustomDecoderHooks...), |
| 113 | Result: result, |
| 114 | WeaklyTypedInput: true, |
| 115 | }) |
| 116 | if err != nil { |
| 117 | return errors.Convert(err) |
| 118 | } |
| 119 | if err := decoder.Decode(input); err != nil { |
| 120 | return errors.Convert(err) |
| 121 | } |
| 122 | return errors.Convert(err) |
| 123 | } |
| 124 | |
| 125 | // Decode decodes `source` into `target`. Pass an optional validator to validate the target. |
| 126 | func Decode(source interface{}, target interface{}, vld *validator.Validate) errors.Error { |