Jsonファイルを読み込み、Goで扱えるデータへ変換します。
サンプルJsonファイル
{
    "Name": "sample_name",
    "Events": [
        {
            "Age": 18,
            "Name": "卒業",
            "DateTime": "2002-03-30 12:12:12"
        },
        {
            "Age": 22,
            "Name": "入社",
            "DateTime": "2005-04-01 09:00:00"
        }
    ]
}サンプル処理
package main
import (
	"encoding/json"
	"fmt"
	"os"
)
// Jsonの内容を格納する構造体
type history struct {
	Name   string
	Events []event
}
type event struct {
	Age      int
	Name     string
	DateTime string
}
func main() {
	h := history{}
	// ファイル読み込み
	f, err := os.Open("sample.json")
	if err != nil {
		return
	}
	// デコード
	json.NewDecoder(f).Decode(&h)
	// 結果を表示
	fmt.Println(h) // {sample_name [{18 卒業 2002-03-30 12:12:12} {22 入社 2005-04-01 09:00:00}]}
}
構造体へデータを設定するには以下の点に注意してください。
- Jsonのキー名と構造体のフィールド名を同じにすること
 - 構造体のフィールド名の先頭は大文字であること