fiber/binder/json.go
M. Efe Çetin 57744ebbe8
🐛 bug: fix EnableSplittingOnParsers is not functional (#3231)
* 🐛 bug: fix EnableSplittingOnParsers is not functional

* remove wrong testcase

* add support for external xml decoders

* improve test coverage

* fix linter

* update

* add reset methods

* improve test coverage

* merge Form and MultipartForm methods

* fix linter

* split reset and putting steps

* fix linter
2024-12-25 12:53:14 +01:00

26 lines
518 B
Go

package binder
import (
"github.com/gofiber/utils/v2"
)
// JSONBinding is the JSON binder for JSON request body.
type JSONBinding struct {
JSONDecoder utils.JSONUnmarshal
}
// Name returns the binding name.
func (*JSONBinding) Name() string {
return "json"
}
// Bind parses the request body as JSON and returns the result.
func (b *JSONBinding) Bind(body []byte, out any) error {
return b.JSONDecoder(body, out)
}
// Reset resets the JSONBinding binder.
func (b *JSONBinding) Reset() {
b.JSONDecoder = nil
}