MCPcopy
hub / github.com/gofiber/fiber / JSON

Method JSON

bind.go:302–313  ·  view source on GitHub ↗

JSON binds the body string into the struct. Returns *BindError on parse failure (manual mode) or *Error with status 400 (auto-handling mode).

(out any)

Source from the content-addressed store, hash-verified

300// JSON binds the body string into the struct.
301// Returns *BindError on parse failure (manual mode) or *Error with status 400 (auto-handling mode).
302func (b *Bind) JSON(out any) error {
303 bind := binder.GetFromThePool[*binder.JSONBinding](&binder.JSONBinderPool)
304 bind.JSONDecoder = b.ctx.App().Config().JSONDecoder
305
306 defer releasePooledBinder(&binder.JSONBinderPool, bind)
307
308 if err := b.returnBindErr(bind.Bind(b.ctx.Body(), out), BindSourceBody); err != nil {
309 return err
310 }
311
312 return b.validateStruct(out)
313}
314
315// CBOR binds the body string into the struct.
316// Returns *BindError on parse failure (manual mode) or *Error with status 400 (auto-handling mode).

Callers 1

BodyMethod · 0.95

Calls 7

returnBindErrMethod · 0.95
validateStructMethod · 0.95
releasePooledBinderFunction · 0.85
ConfigMethod · 0.65
AppMethod · 0.65
BindMethod · 0.65
BodyMethod · 0.65

Tested by

no test coverage detected