| 127 | } |
| 128 | |
| 129 | func makeSNode(node *yaml.Node) *SNode { |
| 130 | var k string |
| 131 | switch node.Kind { |
| 132 | case yaml.DocumentNode: |
| 133 | k = "Document" |
| 134 | case yaml.SequenceNode: |
| 135 | k = "Sequence" |
| 136 | case yaml.MappingNode: |
| 137 | k = "Mapping" |
| 138 | case yaml.ScalarNode: |
| 139 | k = "Scalar" |
| 140 | case yaml.AliasNode: |
| 141 | k = "Alias" |
| 142 | default: |
| 143 | k = "?" |
| 144 | } |
| 145 | |
| 146 | content := make([]*SNode, 0) |
| 147 | if node.Content != nil { |
| 148 | for _, child := range node.Content { |
| 149 | if child == nil { |
| 150 | content = append(content, &SNode{Kind: "?", Value: "nil!"}) |
| 151 | } else { |
| 152 | content = append(content, makeSNode(child)) |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | s := SNode{Kind: k, Value: node.Value, Content: content, Anchor: node.Anchor} |
| 158 | return &s |
| 159 | } |
| 160 | |
| 161 | // Convert a node to a shortened JSON for easier debugging |
| 162 | func ToSJson(node *yaml.Node) string { |