mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-13 22:38:04 +00:00
Can process numeric keys
Fixes: https://github.com/mikefarah/yq/issues/215
This commit is contained in:
parent
f8c1c3c1b4
commit
2dbde6b9fb
@ -10,7 +10,7 @@ import (
|
|||||||
func entryInSlice(context yaml.MapSlice, key interface{}) *yaml.MapItem {
|
func entryInSlice(context yaml.MapSlice, key interface{}) *yaml.MapItem {
|
||||||
for idx := range context {
|
for idx := range context {
|
||||||
var entry = &context[idx]
|
var entry = &context[idx]
|
||||||
if entry.Key == key {
|
if fmt.Sprintf("%v", entry.Key) == key {
|
||||||
return entry
|
return entry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,6 +115,7 @@ func writeArray(context interface{}, paths []string, value interface{}) []interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readMap(context yaml.MapSlice, head string, tail []string) (interface{}, error) {
|
func readMap(context yaml.MapSlice, head string, tail []string) (interface{}, error) {
|
||||||
|
log.Debugf("readingMap %v with key %v\n", context, head)
|
||||||
if head == "*" {
|
if head == "*" {
|
||||||
return readMapSplat(context, tail)
|
return readMapSplat(context, tail)
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,15 @@ b:
|
|||||||
assertResult(t, 2, got)
|
assertResult(t, 2, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadMap_numberKey(t *testing.T) {
|
||||||
|
var data = parseData(`
|
||||||
|
---
|
||||||
|
200: things
|
||||||
|
`)
|
||||||
|
got, _ := readMap(data, "200", []string{})
|
||||||
|
assertResult(t, "things", got)
|
||||||
|
}
|
||||||
|
|
||||||
func TestReadMap_splat(t *testing.T) {
|
func TestReadMap_splat(t *testing.T) {
|
||||||
var data = parseData(`
|
var data = parseData(`
|
||||||
---
|
---
|
||||||
|
Loading…
Reference in New Issue
Block a user