fix: Allow unmarshal json to tolerate null datetimes (#27)

Signed-off-by: James Dobson <jdobson@guidewire.com>
This commit is contained in:
kcao-guidewire
2021-07-14 20:06:27 -04:00
committed by GitHub
parent 85fcf2aaf6
commit 80112bb5a9

View File

@@ -15,6 +15,11 @@ func (t jsonTime) MarshalJSON() ([]byte, error) {
func (t *jsonTime) UnmarshalJSON(s []byte) (err error) {
r := strings.Replace(string(s), `"`, ``, -1)
if r == "null" {
*(*time.Time)(t) = time.Time{}
return
}
q, err := strconv.ParseInt(r, 10, 64)
if err != nil {
return err