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