blob: d8f56975f97ffece8278961b3fa53c6edca58209 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package protocol
import (
"encoding/json"
"time"
)
type TimeStamp time.Time
func (t *TimeStamp) UnmarshalJSON(data []byte) error {
var ts int64
err := json.Unmarshal(data, &ts)
if err != nil {
return err
}
*t = TimeStamp(time.UnixMilli(ts))
return nil
}
func (t TimeStamp) MarshalJSON() ([]byte, error) {
return json.Marshal(time.Time(t).UnixMilli())
}
type Observation struct {
Time TimeStamp `json:"time"`
Target Target `json:"target"`
Online bool `json:"online"`
Latency uint32 `json:"latency"`
}
|