We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 07acd2e commit 2d2e620Copy full SHA for 2d2e620
observation/observation.go
@@ -35,3 +35,20 @@ func (o *Observation) MarshalJSON() ([]byte, error) {
35
Alias: (*Alias)(o),
36
})
37
}
38
+
39
+func (o *Observation) UnmarshalJSON(data []byte) error {
40
+ type Alias Observation
41
+ tmp := &struct {
42
+ FirstSeen int64 `json:"time_first"`
43
+ LastSeen int64 `json:"time_last"`
44
+ *Alias
45
+ }{
46
+ Alias: (*Alias)(o),
47
+ }
48
+ if err := json.Unmarshal(data, &tmp); err != nil {
49
+ return err
50
51
+ o.FirstSeen = time.Unix(tmp.FirstSeen, 0)
52
+ o.LastSeen = time.Unix(tmp.LastSeen, 0)
53
+ return nil
54
+}
0 commit comments