This is a creation in Article, where the information may have evolved or changed.
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. Fixed version
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)