DecodeJSONInterface decodes the supported JSON input types and stores the result in the value pointed by toValue. If toValue is not a compatible type, or an error occurs while decoding DecodeJSONInterface will return an error. The supported input JSON types are: bool -> JSON boolean float64 -> JSO
(input interface{}, toValue interface{})
| 32 | // nil -> JSON null |
| 33 | // |
| 34 | func (d *Decoder) DecodeJSONInterface(input interface{}, toValue interface{}) error { |
| 35 | if document.IsNoSerde(toValue) { |
| 36 | return fmt.Errorf("unsupported type: %T", toValue) |
| 37 | } |
| 38 | |
| 39 | v := reflect.ValueOf(toValue) |
| 40 | |
| 41 | if v.Kind() != reflect.Ptr || v.IsNil() || !v.IsValid() { |
| 42 | return &document.InvalidUnmarshalError{Type: reflect.TypeOf(toValue)} |
| 43 | } |
| 44 | |
| 45 | return d.decode(input, v, serde.Tag{}) |
| 46 | } |
| 47 | |
| 48 | func (d *Decoder) decode(jv interface{}, rv reflect.Value, tag serde.Tag) error { |
| 49 | if jv == nil { |