-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.go
25 lines (23 loc) · 689 Bytes
/
test.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
package main
import (
"encoding/json"
"fmt"
//"reflect"
)
func main() {
//in := []byte(`{ "votes": { "option_A": "3" } }`)
//fmt.Println(reflect.TypeOf(`{ "votes": { "option_A": "3" } }`))
//var raw map[string]interface{}
//json.Unmarshal(in, &raw)
//raw["count"] = 1
//out, _ := json.Marshal(raw)
//println(string(out))
str:= "{\"access_token\":\"uAUS6o5g-9rFWjYt39LYa7TKqiMVsIfCGPEN4IZzdAk5-T-ryVhL7xb8kYciuU_m\",\"expires_in\":7200}"
var dat map[string]interface{}
if err := json.Unmarshal([]byte(str), &dat); err == nil {
fmt.Println(dat)
fmt.Println(dat["expires_in"])
} else {
fmt.Println(err)
}
}