34 lines
545 B
Go
34 lines
545 B
Go
package handlers
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
)
|
|
|
|
type optionalNullableString struct {
|
|
set bool
|
|
value *string
|
|
}
|
|
|
|
func (o *optionalNullableString) UnmarshalJSON(data []byte) error {
|
|
o.set = true
|
|
if bytes.Equal(bytes.TrimSpace(data), []byte("null")) {
|
|
o.value = nil
|
|
return nil
|
|
}
|
|
var value string
|
|
if err := json.Unmarshal(data, &value); err != nil {
|
|
return err
|
|
}
|
|
o.value = &value
|
|
return nil
|
|
}
|
|
|
|
func (o optionalNullableString) Set() bool {
|
|
return o.set
|
|
}
|
|
|
|
func (o optionalNullableString) Value() *string {
|
|
return o.value
|
|
}
|