-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsonex.go
52 lines (45 loc) · 984 Bytes
/
jsonex.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
package main
import (
"encoding/json"
"fmt"
"os"
"time"
)
type Image struct {
Id int `json: "id"`
Md5 string `json: "md5"`
Time string `json: "time"`
location string `json: "location"`
}
func main() {
t := time.Now().Format(time.RFC1123)
fmt.Println("time now : ", t)
img := Image{
Id: 10,
Md5: "kubsdjbjs32",
Time: t,
location: "http://www.google.com",
}
// img2 := Image{
// Id: 11,
// Md5: "jkbsdfk",
// Time: t,
// location: "http://www.tekion.com",
// }
// img3 := Image{
// Id: 12,
// Md5: "jksdkhb4bsdfk",
// Time: t,
// location: "http://www.yahoo.com",
// }
// Create JSON from the instance data.
b, _ := json.MarshalIndent(img, "", " ")
// c, _ := json.MarshalIndent(img2, "", " ")
// d, _ := json.MarshalIndent(img3, "", " ")
// Convert bytes to string.
//s := string(b)
//fmt.Println(s)
//fmt.Println((c))
os.Stdout.Write(b)
//fmt.Println(string(d))
}