yq/pkg/yqlib/encoder.go

28 lines
512 B
Go
Raw Normal View History

2020-01-10 11:01:59 +00:00
package yqlib
import (
"io"
)
type Encoder interface {
Encode(writer io.Writer, node *CandidateNode) error
PrintDocumentSeparator(writer io.Writer) error
PrintLeadingContent(writer io.Writer, content string) error
CanHandleAliases() bool
2020-01-10 11:01:59 +00:00
}
func mapKeysToStrings(node *CandidateNode) {
if node.Kind == MappingNode {
for index, child := range node.Content {
if index%2 == 0 { // its a map key
child.Tag = "!!str"
}
}
}
for _, child := range node.Content {
mapKeysToStrings(child)
}
}