MCPcopy
hub / github.com/gin-gonic/gin / JSON

Method JSON

context.go:1205–1207  ·  view source on GitHub ↗

JSON serializes the given struct as JSON into the response body. It also sets the Content-Type as "application/json".

(code int, obj any)

Source from the content-addressed store, hash-verified

1203// JSON serializes the given struct as JSON into the response body.
1204// It also sets the Content-Type as "application/json".
1205func (c *Context) JSON(code int, obj any) {
1206 c.Render(code, render.JSON{Data: obj})
1207}
1208
1209// AsciiJSON serializes the given struct as JSON into the response body with unicode to ASCII string.
1210// It also sets the Content-Type as "application/json".

Callers 2

AbortWithStatusJSONMethod · 0.95
NegotiateMethod · 0.95

Calls 1

RenderMethod · 0.95

Tested by

no test coverage detected