Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions data_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,35 @@ func (id *ID) UnmarshalJSON(data []byte) error {
return json.Unmarshal(data, (*string)(id))
}

type IntPairs [][]int

func (p *IntPairs) UnmarshalJSON(data []byte) error {
var raw [][]json.Number
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if raw == nil {
*p = nil
return nil
}
out := make(IntPairs, len(raw))
for i, pair := range raw {
out[i] = make([]int, len(pair))
for j, n := range pair {
if n == "" {
continue
}
v, err := n.Int64()
if err != nil {
return err
}
out[i][j] = int(v)
}
}
*p = out
return nil
}

// Timestamp is the number of seconds since the UNIX epoch
type Timestamp uint64

Expand Down
2 changes: 1 addition & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ type Attachment struct {
Latitude string `json:"lat,omitempty"`
Longitude string `json:"lng,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Charmap [][]int `json:"charmap,omitempty"`
Charmap IntPairs `json:"charmap,omitempty"`
ReplyID ID `json:"reply_id,omitempty"`
BaseReplyID ID `json:"base_reply_id,omitempty"`
UserID ID `json:"user_id,omitempty"`
Expand Down
Loading