MCPcopy Index your code
hub / github.com/labstack/echo / MustJSONUnmarshaler

Method MustJSONUnmarshaler

binder.go:367–382  ·  view source on GitHub ↗

MustJSONUnmarshaler requires parameter value to exist to bind to destination implementing json.Unmarshaler interface. Returns error when value does not exist

(sourceParam string, dest json.Unmarshaler)

Source from the content-addressed store, hash-verified

365// MustJSONUnmarshaler requires parameter value to exist to bind to destination implementing json.Unmarshaler interface.
366// Returns error when value does not exist
367func (b *ValueBinder) MustJSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder {
368 if b.failFast && b.errors != nil {
369 return b
370 }
371
372 tmp := b.ValueFunc(sourceParam)
373 if tmp == "" {
374 b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "required field value is empty", nil))
375 return b
376 }
377
378 if err := dest.UnmarshalJSON([]byte(tmp)); err != nil {
379 b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to json.Unmarshaler interface", err))
380 }
381 return b
382}
383
384// TextUnmarshaler binds parameter to destination implementing encoding.TextUnmarshaler interface
385func (b *ValueBinder) TextUnmarshaler(sourceParam string, dest encoding.TextUnmarshaler) *ValueBinder {

Callers 1

Calls 2

setErrorMethod · 0.95
UnmarshalJSONMethod · 0.80

Tested by 1