package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	r := gin.Default()
	r.GET("/json", func(c *gin.Context) {
		data := gin.H{"name": "Gin",
			"description": "Web Framework",}
		c.JSON(http.StatusOK, data)
	})
	r.Run(":9000")
}
package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)
type msg struct {
	Name string
	Age int
}
func main() {
	r := gin.Default()
	r.GET("/json", func(c *gin.Context) {
		// 结构体方式
		data := msg{
			"Golang", 11,
		}
		c.JSON(http.StatusOK, data)
	})
	r.Run(":9000")
}