encoding/jsonUnmarshal

以下是一个简单的示例,假设您有一个JSON数据如下:

{
    "name": "Alice",
    "age": 25,
    "email": "alice@example.com"
}

然后您可以定义一个结构体来表示该JSON数据的字段:

type Person struct {
    Name  string `json:"name"`
    Age   int    `json:"age"`
    Email string `json:"email"`
}
Unmarshal
jsonStr := `{"name": "Alice", "age": 25, "email": "alice@example.com"}`
var person Person
err := json.Unmarshal([]byte(jsonStr), &person)
if err != nil {
    // 处理错误
}
person

希望这可以帮助您开始解析JSON数据!如果您有更具体的问题,请随时问我。