Merge pull request #21 from javierprovecho/master

Fix JSON Struct example
This commit is contained in:
Manu Mtz.-Almeida 2014-07-02 11:54:39 +02:00
commit 3bfbf986a2

View File

@ -190,12 +190,16 @@ func main() {
r.GET("/moreJSON", func(c *gin.Context) {
// You also can use a struct
var msg struct {
Name string `json:"user"`
Message string
Status int
Number int
}
msg.Name = "Lena"
msg.Message = "hey"
msg.Status = 200
c.JSON(200, msg.Status)
msg.Number = 123
// Note that msg.Name becomes "user" in the JSON
// Will output : {"user": "Lena", "Message": "hey", "Number": 123}
c.JSON(200, msg)
})
r.GET("/someXML", func(c *gin.Context) {