Skip to content

Commit

Permalink
Handle null timestamp (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmmarslender authored May 21, 2024
1 parent 8e2421a commit 5be5193
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/types/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ func (t Timestamp) MarshalJSON() ([]byte, error) {

// UnmarshalJSON unmarshals from uint64
func (t *Timestamp) UnmarshalJSON(data []byte) error {
// Check if the data is the JSON "null"
if string(data) == "null" {
// Handle the null case
*t = Timestamp{}
return nil
}

// Split accounts for unix timestamps in float form (1668050986.646834)
// In these cases, we just parse the seconds and ignore the decimal
splits := bytes.Split(data, []byte(`.`))
Expand Down

0 comments on commit 5be5193

Please sign in to comment.