-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
77 lines (69 loc) · 1.5 KB
/
main.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package main
import (
"encoding/json"
"fmt"
)
// Opus 作品
type Opus struct {
Type string
Title string
}
// Actress 女演员
type Actress struct {
Name string
Birthday string
BirthPlace string
Opus map[string]Opus
}
type Extra struct{}
func main() {
jsonData := []byte(`{
"name":"迪丽热巴",
"birthday":"1992-06-03",
"birthPlace":"新疆乌鲁木齐市",
"opus":{
"2013":{
"Type":"近代革命剧",
"Title":"《阿娜尔罕》"
},
"2014":{
"Type":"奇幻剧",
"Title":"《逆光之恋》"
},
"2015":{
"Type":"爱情剧",
"Title":"《克拉恋人》"
}
}
}`)
str := "{\"name\"}"
ext := Extra{}
err := json.Unmarshal([]byte(str), &ext)
//fmt.Println(string([]byte(str)))
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(ext)
var actress Actress
err = json.Unmarshal(jsonData, &actress)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Printf("姓名:%s\n", actress.Name)
fmt.Printf("生日:%s\n", actress.Birthday)
fmt.Printf("出生地:%s\n", actress.BirthPlace)
fmt.Println("作品:")
for index, value := range actress.Opus {
fmt.Printf("\t日期:%s\n", index)
fmt.Printf("\t\t分类:%s\n", value.Type)
fmt.Printf("\t\t标题:%s\n", value.Title)
}
// 测试
// 测试忽略add
// 测试忽略
// 修复缺陷
// 新建了一个serverfix分支
// testing分支
}