Decode takes an input structure and uses reflection to translate it to the output structure. output must be a pointer to a map or struct.
(input interface{}, output interface{})
| 304 | // Decode takes an input structure and uses reflection to translate it to |
| 305 | // the output structure. output must be a pointer to a map or struct. |
| 306 | func Decode(input interface{}, output interface{}) error { |
| 307 | config := &DecoderConfig{ |
| 308 | Metadata: nil, |
| 309 | Result: output, |
| 310 | } |
| 311 | |
| 312 | decoder, err := NewDecoder(config) |
| 313 | if err != nil { |
| 314 | return err |
| 315 | } |
| 316 | |
| 317 | return decoder.Decode(input) |
| 318 | } |
| 319 | |
| 320 | // WeakDecode is the same as Decode but is shorthand to enable |
| 321 | // WeaklyTypedInput. See DecoderConfig for more info. |