Documentation
¶
Overview ¶
Package optional implements an Optional[T] type for JSON use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Optional ¶
Optional is an optional value. When unmarshaling a struct, if the value is not present, o.Present and o.Null are false, and o.Value is the zero value for T.
Note that Go doesn't let us control marshaling as much as unmarshaling, so the reverse is not possible. Optional is marshaled as null if o.Null is true or o.Present is false.
func NewWithValue ¶
NewWithValue returns an Optional[T] with the value set to v.
func (Optional[T]) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*Optional[T]) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
Click to show internal directories.
Click to hide internal directories.