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 {
2023-04-08 09:56:35 +00:00
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
}
2023-04-08 09:56:35 +00:00
func mapKeysToStrings(node *CandidateNode) {
2023-04-08 09:56:35 +00:00
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)
}
}