package main import ( "encoding/json" "net/http" "github.com/codegangsta/martini" "github.com/codegangsta/martini-contrib/render" ) type User struct { Name string `json:"name"` Email string `json:"email"` Enabled bool `json:"enabled"` } func main() { r := martini.Classic() r.Use(render.Renderer(render.Options{ IndentJSON: true, })) r.Get("/users", func(w http.ResponseWriter, r *http.Request, ren render.Render) { users := []User{ {Name: "John Doe", Email: "[email protected]", Enabled: true}, {Name: "Jane Doe", Email: "[email protected]", Enabled: false}, } ren.JSON(http.StatusOK, users) }) r.Run() }In this example, the martini-contrib.render package is imported and used to define a simple Martini server that responds to GET requests to the "/users" endpoint with a JSON array of User structs. The package's "Renderer" middleware is used to enable the JSON rendering capabilities of martini-contrib.render. The "ren" parameter, which is a render.Render interface, is used to render the JSON response using the "JSON" method. The "JSON" method takes two parameters; the first is the response status code, and the second is the data to be rendered as JSON. The package options provide an option 'ContentType' to select return format if user hasn't defined other types. For example the format of a normal HTTP should be like this: options := render.Options{ContentType: "text/html"} In this way the JSON is formatted in HTML tag conventions.