golang的json数据解析

Posted kekemuyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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"])
    }

以上是关于golang的json数据解析的主要内容,如果未能解决你的问题,请参考以下文章