-
Notifications
You must be signed in to change notification settings - Fork 6
/
unmarshaller.go
56 lines (49 loc) · 1.35 KB
/
unmarshaller.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"encoding/json"
"io/ioutil"
)
type Channel struct {
ID string `json:"id"`
Name string `json:"name"`
Created json.Number `json:"created"`
}
type User struct {
ID string `json:"id"`
Name string `json:"name"`
Profile UserProfile `json:"profile"`
}
type UserProfile struct {
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
ReamName string `json:"real_name"`
ReamNameNormalized string `json:"real_name_normalized"`
Title string `json:"title"`
Image24 string `json:"image_24"`
}
type Message struct {
User string `json:"user"`
BotID string `json:"bot_id"`
Text string `json:"text"`
Subtype string `json:"subtype"`
Ts string `json:"ts"`
}
func ReadChannels(channelJSONFilename string) []Channel {
var channels []Channel
body, _ := ioutil.ReadFile(channelJSONFilename)
_ = json.Unmarshal(body, &channels)
return channels
}
func ReadUsers(userJSONFilename string) []User {
var users []User
body, _ := ioutil.ReadFile(userJSONFilename)
_ = json.Unmarshal(body, &users)
return users
}
func ReadHistory(historyJSONFilename string) []Message {
var messages []Message
body, _ := ioutil.ReadFile(historyJSONFilename)
_ = json.Unmarshal(body, &messages)
return messages
}