You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 4, 2025. It is now read-only.
If you need to support custom types (e.g. for custom time formats), you'll need to implement the json.Marshaler and json.Unmarshaler interfaces on the type.
348
+
Custom types are supported for primitive types, only, as attributes. Examples,
349
349
350
350
```go
351
-
// MyTimeFormat is a custom format I invented for fun
352
-
constMyTimeFormat = "The time is 15:04:05. The year is 2006, and it is day 2 of January."
353
-
354
-
// MyTime is a custom type used to handle the custom time format
355
-
typeMyTimestruct {
356
-
time.Time
357
-
}
358
-
359
-
// UnmarshalJSON to implement the json.Unmarshaler interface
360
-
func(m *MyTime) UnmarshalJSON(b []byte) error {
361
-
t, err:= time.Parse(MyTimeFormat, string(b))
362
-
if err != nil {
363
-
return err
364
-
}
365
-
366
-
m.Time = t
351
+
typeCustomIntTypeint
352
+
typeCustomFloatTypefloat64
353
+
typeCustomStringTypestring
354
+
```
367
355
368
-
returnnil
369
-
}
356
+
Types like following are not supported, but may be in the future:
370
357
371
-
// MarshalJSON to implement the json.Marshaler interface
0 commit comments