The API uses the optional
package to distinguish between three states for a field in a JSON payload:
- Omitted: The field is not present in the JSON request body.
- Set to
null
: The field is present with an explicitnull
value (e.g.,"description": null
). This is used to unset or clear a field's value. - Set to a value: The field is present with a non-
null
value (e.g.,"description": "my description"
or"description": ""
).
type Input struct {
Description optional.String `json:"description"`