MCPcopy Create free account
hub / github.com/goccy/go-yaml / encodeMapItem

Method encodeMapItem

encode.go:640–658  ·  view source on GitHub ↗
(ctx context.Context, item MapItem, column int)

Source from the content-addressed store, hash-verified

638}
639
640func (e *Encoder) encodeMapItem(ctx context.Context, item MapItem, column int) (*ast.MappingValueNode, error) {
641 k := reflect.ValueOf(item.Key)
642 v := reflect.ValueOf(item.Value)
643 value, err := e.encodeValue(ctx, v, column)
644 if err != nil {
645 return nil, err
646 }
647 if e.isMapNode(value) {
648 value.AddColumn(e.indentNum)
649 }
650 if e.isTagAndMapNode(value) {
651 value.AddColumn(e.indentNum)
652 }
653 return ast.MappingValue(
654 token.New("", "", e.pos(column)),
655 e.encodeString(k.Interface().(string), column),
656 value,
657 ), nil
658}
659
660func (e *Encoder) encodeMapSlice(ctx context.Context, value MapSlice, column int) (*ast.MappingNode, error) {
661 node := ast.Mapping(token.New("", "", e.pos(column)), e.isFlowStyle)

Callers 2

encodeValueMethod · 0.95
encodeMapSliceMethod · 0.95

Calls 8

encodeValueMethod · 0.95
isMapNodeMethod · 0.95
isTagAndMapNodeMethod · 0.95
posMethod · 0.95
encodeStringMethod · 0.95
MappingValueFunction · 0.92
NewFunction · 0.92
AddColumnMethod · 0.65

Tested by

no test coverage detected