Documentation
¶
Index ¶
- func DateMarshalBasic(enc *jsontext.Encoder, d civil.Date) error
- func DateMarshalBasicFor(names ...string) func(*jsontext.Encoder, civil.Date) error
- func DateMarshalIntUnix(enc *jsontext.Encoder, d civil.Date) error
- func DateMarshalIntUnixFor(names ...string) func(*jsontext.Encoder, civil.Date) error
- func DateMarshalZeroAsNull(enc *jsontext.Encoder, d civil.Date) error
- func DateUnmarshalBasic(dec *jsontext.Decoder, d *civil.Date) error
- func DateUnmarshalBasicFor(names ...string) func(*jsontext.Decoder, *civil.Date) error
- func DateUnmarshalEmptyAsZero(dec *jsontext.Decoder, d *civil.Date) error
- func DateUnmarshalIntUnix(dec *jsontext.Decoder, d *civil.Date) error
- func DateUnmarshalIntUnixFor(names ...string) func(*jsontext.Decoder, *civil.Date) error
- func DurationMarshalIntSeconds(enc *jsontext.Encoder, d time.Duration) error
- func DurationMarshalString(enc *jsontext.Encoder, d time.Duration) error
- func DurationUnmarshalIntSeconds(dec *jsontext.Decoder, d *time.Duration) error
- func DurationUnmarshalString(dec *jsontext.Decoder, d *time.Duration) error
- func Float64UnmarshalStringOrNumber(dec *jsontext.Decoder, f *float64) error
- func HTTPHeaderMarshal(enc *jsontext.Encoder, m http.Header) error
- func HTTPHeaderUnmarshal(dec *jsontext.Decoder, h *http.Header) error
- func OrderedMapMarshal[M ~map[K]V, K cmp.Ordered, V any](enc *jsontext.Encoder, m M) error
- func ReadFile[T any](name string, opts ...json.Options) (T, error)
- func TimeMarshalIntUnix(enc *jsontext.Encoder, t time.Time) error
- func TimeMarshalIntUnixFor(names ...string) func(*jsontext.Encoder, time.Time) error
- func TimeMarshalIntUnixMilli(enc *jsontext.Encoder, t time.Time) error
- func TimeMarshalIntUnixMilliFor(names ...string) func(*jsontext.Encoder, time.Time) error
- func TimeUnmarshalEmptyAsZero(dec *jsontext.Decoder, t *time.Time) error
- func TimeUnmarshalIntUnix(dec *jsontext.Decoder, d *time.Time) error
- func TimeUnmarshalIntUnixFor(names ...string) func(*jsontext.Decoder, *time.Time) error
- func TimeUnmarshalIntUnixMilli(dec *jsontext.Decoder, d *time.Time) error
- func TimeUnmarshalIntUnixMilliFor(names ...string) func(*jsontext.Decoder, *time.Time) error
- func TimeUnmarshalStringOrIntUnix(dec *jsontext.Decoder, d *time.Time) error
- func URLMarshal(enc *jsontext.Encoder, u url.URL) error
- func URLUnmarshal(dec *jsontext.Decoder, u *url.URL) error
- func WriteFile[T any](name string, data T, opts ...json.Options) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DateMarshalBasic ¶
DateMarshalBasic is a custom marshaler for civil.Date, marshaling them as strings in ISO 8601's basic form, without separators, such as "20260320". The zero date marshals as null.
func DateMarshalBasicFor ¶
DateMarshalBasicFor returns a marshaler for civil.Date that writes, as DateMarshalBasic does, the dates held by an object member of one of the names given, or by an array such a member holds; see DateMarshalIntUnixFor.
func DateMarshalIntUnix ¶
DateMarshalIntUnix is a custom marshaler for civil.Date, marshaling them as integers representing unix time.
func DateMarshalIntUnixFor ¶
DateMarshalIntUnixFor returns a marshaler for civil.Date that writes, as DateMarshalIntUnix does, the dates held by an object member of one of the names given, or by an array such a member holds. It leaves any other date to the marshaler after it, or to the default, which writes a string: for an API that writes some dates as unix time and others as strings.
func DateMarshalZeroAsNull ¶
DateMarshalZeroAsNull is a custom marshaler for civil.Date that writes the zero date as null, where civil.Date itself would write "0000-00-00", a date that does not exist and that no decoder reads back; null reads back as the zero date. It leaves every other date to civil.Date itself, or to a marshaler joined after it.
func DateUnmarshalBasic ¶
DateUnmarshalBasic is a custom unmarshaler for civil.Date, unmarshaling them from strings in ISO 8601's basic form, such as "20260320". Null unmarshals as the zero date.
func DateUnmarshalBasicFor ¶
DateUnmarshalBasicFor returns an unmarshaler for civil.Date that reads, as DateUnmarshalBasic does, the dates held by an object member of one of the names given, or by an array such a member holds; see DateMarshalIntUnixFor.
func DateUnmarshalEmptyAsZero ¶
DateUnmarshalEmptyAsZero is a custom unmarshaler for civil.Date that reads an empty string as the zero date, as an API that leaves a date out may send, and anything else as civil.Date itself does.
func DateUnmarshalIntUnix ¶
DateUnmarshalIntUnix is a custom unmarshaler for civil.Date, unmarshaling them from integers and assuming they represent unix time.
func DateUnmarshalIntUnixFor ¶
DateUnmarshalIntUnixFor returns an unmarshaler for civil.Date that reads, as DateUnmarshalIntUnix does, the dates held by an object member of one of the names given, or by an array such a member holds; see DateMarshalIntUnixFor.
func DurationMarshalIntSeconds ¶
DurationMarshalIntSeconds is a custom marshaler for time.Duration, marshaling them as integers representing seconds.
func DurationMarshalString ¶
DurationMarshalString encodes a time.Duration as a JSON string using the canonical units format (e.g. "1h30m", "500ms").
func DurationUnmarshalIntSeconds ¶
DurationUnmarshalIntSeconds is a custom unmarshaler for time.Duration, unmarshaling them from integers and assuming they represent seconds.
func DurationUnmarshalString ¶
DurationUnmarshalString decodes a JSON string into a time.Duration by parsing it with time.ParseDuration.
func Float64UnmarshalStringOrNumber ¶
Float64UnmarshalStringOrNumber is a custom unmarshaler for float64, unmarshaling them from a JSON number or from a string holding one, such as "9.5", as an API that sends numbers as strings does, but for the odd number. Null leaves f as it is.
func HTTPHeaderMarshal ¶
HTTPHeaderMarshal is a custom marshaler for http.Header, marshaling values as a single strings. It also marshals the keys in their canonical form. Note that we omit keys that don't have a value.
func HTTPHeaderUnmarshal ¶
HTTPHeaderUnmarshal is a custom unmarshaler for http.Header, unmarshaling values as single strings or, as other tools record them, lists of strings.
func OrderedMapMarshal ¶
OrderedMapMarshal is a custom marshaler for maps with ordered keys, marshaling them in an ordered fashion.
func TimeMarshalIntUnix ¶
TimeMarshalIntUnix is a custom marshaler for time.Time, marshaling them as integers representing unix time.
func TimeMarshalIntUnixFor ¶
TimeMarshalIntUnixFor returns a marshaler for time.Time that writes, as TimeMarshalIntUnix does, the times held by an object member of one of the names given, or by an array such a member holds; see DateMarshalIntUnixFor.
func TimeMarshalIntUnixMilli ¶
TimeMarshalIntUnixMilli is a custom marshaler for time.Time, marshaling them as integers representing unix time in milliseconds.
func TimeMarshalIntUnixMilliFor ¶
TimeMarshalIntUnixMilliFor returns a marshaler for time.Time that writes, as TimeMarshalIntUnixMilli does, the times held by an object member of one of the names given, or by an array such a member holds; see DateMarshalIntUnixFor.
func TimeUnmarshalEmptyAsZero ¶
TimeUnmarshalEmptyAsZero is a custom unmarshaler for time.Time that reads an empty string as the zero time, as an API that leaves a time out may send, and anything else as time.Time itself does.
func TimeUnmarshalIntUnix ¶
TimeUnmarshalIntUnix is a custom unmarshaler for time.Time, unmarshaling them from integers and assuming they represent unix time.
func TimeUnmarshalIntUnixFor ¶
TimeUnmarshalIntUnixFor returns an unmarshaler for time.Time that reads, as TimeUnmarshalIntUnix does, the times held by an object member of one of the names given, or by an array such a member holds; see DateMarshalIntUnixFor.
func TimeUnmarshalIntUnixMilli ¶
TimeUnmarshalIntUnixMilli is a custom unmarshaler for time.Time, unmarshaling them from integers representing unix time in milliseconds.
func TimeUnmarshalIntUnixMilliFor ¶
TimeUnmarshalIntUnixMilliFor returns an unmarshaler for time.Time that reads, as TimeUnmarshalIntUnixMilli does, the times held by an object member of one of the names given, or by an array such a member holds; see DateMarshalIntUnixFor.
func TimeUnmarshalStringOrIntUnix ¶
TimeUnmarshalStringOrIntUnix unmarshals a time.Time from either an RFC3339 or timeAltLayout string, or an integer representing unix seconds or, from 10^11 on, unix milliseconds (see [unixSecondsOrMilli]). Null and the empty string decode as the zero time.
func URLMarshal ¶
URLMarshal is a custom marshaler for URL values, marshaling them as strings.
func URLUnmarshal ¶
URLUnmarshal is a custom unmarshaler for URL values, unmarshaling them from strings.
Types ¶
This section is empty.