MCPcopy
hub / github.com/protocolbuffers/protobuf-go / marshalMap

Method marshalMap

encoding/protojson/encode.go:365–380  ·  view source on GitHub ↗

marshalMap marshals given protoreflect.Map.

(mmap protoreflect.Map, fd protoreflect.FieldDescriptor)

Source from the content-addressed store, hash-verified

363
364// marshalMap marshals given protoreflect.Map.
365func (e encoder) marshalMap(mmap protoreflect.Map, fd protoreflect.FieldDescriptor) error {
366 e.StartObject()
367 defer e.EndObject()
368
369 var err error
370 order.RangeEntries(mmap, order.GenericKeyOrder, func(k protoreflect.MapKey, v protoreflect.Value) bool {
371 if err = e.WriteName(k.String()); err != nil {
372 return false
373 }
374 if err = e.marshalSingular(v, fd.MapValue()); err != nil {
375 return false
376 }
377 return true
378 })
379 return err
380}

Callers 2

marshalStructMethod · 0.95
marshalValueMethod · 0.95

Calls 7

marshalSingularMethod · 0.95
RangeEntriesFunction · 0.92
StartObjectMethod · 0.80
EndObjectMethod · 0.80
StringMethod · 0.65
MapValueMethod · 0.65
WriteNameMethod · 0.45

Tested by

no test coverage detected