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

Method JSONUnmarshaler

binder.go:349–363  ·  view source on GitHub ↗

JSONUnmarshaler binds parameter to destination implementing json.Unmarshaler interface

(sourceParam string, dest json.Unmarshaler)

Source from the content-addressed store, hash-verified

347
348// JSONUnmarshaler binds parameter to destination implementing json.Unmarshaler interface
349func (b *ValueBinder) JSONUnmarshaler(sourceParam string, dest json.Unmarshaler) *ValueBinder {
350 if b.failFast && b.errors != nil {
351 return b
352 }
353
354 tmp := b.ValueFunc(sourceParam)
355 if tmp == "" {
356 return b
357 }
358
359 if err := dest.UnmarshalJSON([]byte(tmp)); err != nil {
360 b.setError(b.ErrorFunc(sourceParam, []string{tmp}, "failed to bind field value to json.Unmarshaler interface", err))
361 }
362 return b
363}
364
365// MustJSONUnmarshaler requires parameter value to exist to bind to destination implementing json.Unmarshaler interface.
366// Returns error when value does not exist

Callers 1

Calls 2

setErrorMethod · 0.95
UnmarshalJSONMethod · 0.80

Tested by 1