mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 13:48:06 +00:00
cf8cfbd865
* Refactor ordered_map into separate files Separate json and xml, from the regular yaml. Makes it possible to compile, without those... * Refactor encoder and decoder creation Use more consistent parameters vs globals Return errors instead of calling panic() * Allow build without json and xml support
30 lines
535 B
Go
30 lines
535 B
Go
package yqlib
|
|
|
|
import (
|
|
"io"
|
|
|
|
yaml "gopkg.in/yaml.v3"
|
|
)
|
|
|
|
type Encoder interface {
|
|
Encode(writer io.Writer, node *yaml.Node) error
|
|
PrintDocumentSeparator(writer io.Writer) error
|
|
PrintLeadingContent(writer io.Writer, content string) error
|
|
CanHandleAliases() bool
|
|
}
|
|
|
|
func mapKeysToStrings(node *yaml.Node) {
|
|
|
|
if node.Kind == yaml.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)
|
|
}
|
|
}
|