如何使用 GitLab CI/CD 快速实现自动化构建与发布
如何使用 GitLab CI/CD 快速实现自动化构建与发布
json 字符串
var jsonStr string
{
"class_id": 1,
"class_name": "一年级",
"stus": [
{
"stu_id": 1,
"stu_name": "stu1",
"age": 18
},{
"stu_id": 2,
"stu_name": "stu2",
"age": 18
},{
"stu_id": 3,
"stu_name": "stu3",
"age": 18
}
]
}
先解析 json 到数据结构 Stu
type Stu struct {
StuId int `json:"stu_id"`
StuName string `json:"stu_name"`
Age int `json:"age"`
}
type Class struct {
ClassId int `json:"class_id"`
ClassName string `json:"class_name"`
Stu []Stu `json:"stu"`
}
func main() {
var class = &Class{}
err := json.Unmarshal([]byte(jsonStr), class)
if err != nil {
return
}
fmt.Println(class.ClassId, ":", class.ClassName)
}
使用第三方库 github.com/bitly/go-simplejson