MCPcopy Index your code
hub / github.com/coder/coder / MarshalJSON

Method MarshalJSON

codersdk/time.go:31–40  ·  view source on GitHub ↗

MarshalJSON implements json.Marshaler.

()

Source from the content-addressed store, hash-verified

29
30// MarshalJSON implements json.Marshaler.
31func (t NullTime) MarshalJSON() ([]byte, error) {
32 if !t.Valid {
33 return []byte("null"), nil
34 }
35 b, err := t.Time.MarshalJSON()
36 if err != nil {
37 return nil, xerrors.Errorf("codersdk.NullTime: json encode failed: %w", err)
38 }
39 return b, nil
40}
41
42// UnmarshalJSON implements json.Unmarshaler.
43func (t *NullTime) UnmarshalJSON(data []byte) error {

Callers 1

TestNullTime_MarshalJSONFunction · 0.95

Calls 1

ErrorfMethod · 0.45

Tested by 1

TestNullTime_MarshalJSONFunction · 0.76