v0.6.0
New Features
Support omitempty
option on JSON marshaling #17
This version brings up the support for the omitempty
option on JSON marshaling. If the property has that option and the value is None[T]
, it omits that property from the serialized JSON string.
example:
type JSONStruct struct {
OmitemptyVal Option[string] `json:"omitemptyVal,omitempty"` // this should be omitted
}
jsonStruct := &JSONStruct{OmitemptyVal: None[string]()}
marshal, err := json.Marshal(jsonStruct)
if err != nil {
return err
}
fmt.Printf("%s\n", marshal) // => {}