Skip to content

Commit

Permalink
Handle null JSONTime Unmarshal
Browse files Browse the repository at this point in the history
Handle the NULL value, when API returns "timestamp": null
  • Loading branch information
rusq authored Aug 31, 2022
1 parent 870ec8a commit 0b2c5fa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions info.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ func (t JSONTime) Time() time.Time {
func (t *JSONTime) UnmarshalJSON(buf []byte) error {
s := bytes.Trim(buf, `"`)

if bytes.EqualFold(s, []byte("null")) {
*t = JSONTime(0)
return nil
}

v, err := strconv.Atoi(string(s))
if err != nil {
return err
Expand Down

0 comments on commit 0b2c5fa

Please sign in to comment.