golang的json数据解析

import (
    "fmt"
    "time"

    "github.com/astaxie/beego"
    "github.com/bitly/go-simplejson"
)
type Datas struct {
        data struct {
            Id     int64     `json:"id"`
            Userid string    `json:"userid"`
            Title  string    `json:"title"`
            Txt    string    `json:"txt"`
            Date   time.Time `json:"date"`
        } `json:"data"`
    }

json, _ := simplejson.NewJson(this.Ctx.Input.RequestBody)
    datas, _ := json.Get("data").Array()

    for _, v := range datas {
        fmt.Println(v)
        temp, _ := v.(map[string]interface{})
        fmt.Println(temp["id"])
    }


2.修正版
type Datas struct {
        Data []struct {
            Id     int64  `json:"id"`
            Userid string `json:"userid"`
            Title  string `json:"title"`
            Txt    string `json:"txt"`
            Date   string `json:"date"`
        } `json:"data"`
    }
    var temp Datas
    err := json.Unmarshal(this.Ctx.Input.RequestBody, &temp)
    fmt.Println(err, temp)