Fix JSON Struct example

This commit is contained in:
Javier Provecho 2014-07-02 11:47:55 +02:00
parent 5eb5080c7c
commit 9ea9e0fd51

View File

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