1
2
3
4
{
"name": "jack",
"age": 21
}
1
2
3
4
5
6
7
8
type User struct {
Name string `json:"name"`
Age int `json:"age"`
}

user := User{}
json.Unmarshal([]byte(jsonStr), &user)