diff --git a/request.go b/request.go index a7bb0b1..5ed38d8 100644 --- a/request.go +++ b/request.go @@ -425,6 +425,11 @@ func unmarshalAttribute( return } + // Field was a json.RawMessage + if fieldValue.Type() == reflect.TypeOf(json.RawMessage{}) { + value, err = handleRawMessage(attribute) + } + // As a final catch-all, ensure types line up to avoid a runtime panic. if fieldValue.Kind() != value.Kind() { err = ErrInvalidType @@ -434,6 +439,14 @@ func unmarshalAttribute( return } +func handleRawMessage(attribute interface{}) (reflect.Value, error) { + raw, err := json.Marshal(attribute) + if err != nil { + return reflect.Value{}, err + } + return reflect.ValueOf(raw), nil +} + func handleStringSlice(attribute interface{}) (reflect.Value, error) { v := reflect.ValueOf(attribute) values := make([]string, v.Len())