MCPcopy Create free account
hub / github.com/blues/note / marshalerEncoder

Function marshalerEncoder

jsonxt/encode.go:445–463  ·  view source on GitHub ↗
(e *encodeState, v reflect.Value, opts encOpts)

Source from the content-addressed store, hash-verified

443}
444
445func marshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) {
446 if v.Kind() == reflect.Ptr && v.IsNil() {
447 e.WriteString("null")
448 return
449 }
450 m, ok := v.Interface().(Marshaler)
451 if !ok {
452 e.WriteString("null")
453 return
454 }
455 b, err := m.MarshalJSON()
456 if err == nil {
457 // copy JSON into buffer, checking validity.
458 err = compact(&e.Buffer, b, opts.escapeHTML)
459 }
460 if err != nil {
461 e.error(&MarshalerError{v.Type(), err})
462 }
463}
464
465func addrMarshalerEncoder(e *encodeState, v reflect.Value, _ encOpts) {
466 va := v.Addr()

Callers

nothing calls this directly

Calls 3

compactFunction · 0.85
MarshalJSONMethod · 0.65
errorMethod · 0.45

Tested by

no test coverage detected