mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-15 07:38:14 +00:00
13d1bbb45f
Remove dependency on yaml.Node for internal AST representation. Yaml decoder is now just another decoder.
28 lines
512 B
Go
28 lines
512 B
Go
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
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|