diff --git a/optional_unmarshaljson.go b/optional_unmarshaljson.go index 164fd4c..51e6a1c 100644 --- a/optional_unmarshaljson.go +++ b/optional_unmarshaljson.go @@ -10,11 +10,11 @@ var _ json.Unmarshaler = new(Optional[string]) // UnmarshalJSON makes it so json.Unmarshaler is implemented. func (receiver *Optional[T]) UnmarshalJSON(data []byte) error { - switch interface{}(receiver.value).(type) { - case bool, string, json.Unmarshaler: + switch interface{}(&receiver.value).(type) { + case *bool, *string, json.Unmarshaler: // these are OK. default: - return fmt.Errorf("cannot unmarshal into something of type %T from JSON because parameterized type is ‘%T’ rather than ‘bool’, ‘string’, or ‘json.Unmarshaler’", receiver, receiver.value) + return fmt.Errorf("cannot unmarshal into something of type %T from JSON because pointer to parameterized type is ‘%T’ rather than ‘*bool’, ‘*string’, or ‘json.Unmarshaler’", receiver, &receiver.value) } {