mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixed key issue
This commit is contained in:
parent
d17216de3f
commit
f6c3fab309
@ -130,7 +130,7 @@ func (n *CandidateNode) GetFileIndex() int {
|
|||||||
func (n *CandidateNode) GetKey() string {
|
func (n *CandidateNode) GetKey() string {
|
||||||
keyPrefix := ""
|
keyPrefix := ""
|
||||||
if n.IsMapKey {
|
if n.IsMapKey {
|
||||||
keyPrefix = "key-"
|
keyPrefix = fmt.Sprintf("key-%v-", n.Value)
|
||||||
}
|
}
|
||||||
key := ""
|
key := ""
|
||||||
if n.Key != nil {
|
if n.Key != nil {
|
||||||
|
@ -131,7 +131,7 @@ will output
|
|||||||
- p: a
|
- p: a
|
||||||
isKey: false
|
isKey: false
|
||||||
tag: '!!map'
|
tag: '!!map'
|
||||||
- p: a.c
|
- p: a.b
|
||||||
isKey: true
|
isKey: true
|
||||||
tag: '!!str'
|
tag: '!!str'
|
||||||
- p: a.b
|
- p: a.b
|
||||||
@ -140,6 +140,9 @@ will output
|
|||||||
- p: a.b.0
|
- p: a.b.0
|
||||||
isKey: false
|
isKey: false
|
||||||
tag: '!!str'
|
tag: '!!str'
|
||||||
|
- p: a.c
|
||||||
|
isKey: true
|
||||||
|
tag: '!!str'
|
||||||
- p: a.c
|
- p: a.c
|
||||||
isKey: false
|
isKey: false
|
||||||
tag: '!!str'
|
tag: '!!str'
|
||||||
|
@ -61,7 +61,7 @@ var loadScenarios = []expressionScenario{
|
|||||||
document: `{something: {file: "thing.yml"}, over: {here: [{file: "thing.yml"}]}}`,
|
document: `{something: {file: "thing.yml"}, over: {here: [{file: "thing.yml"}]}}`,
|
||||||
expression: `(.. | select(has("file"))) |= load("../../examples/" + .file)`,
|
expression: `(.. | select(has("file"))) |= load("../../examples/" + .file)`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[], (!!map)::{something: {a: apple is included, b: cool.}, over: {here: [{a: apple is included, b: cool.}]}}\n",
|
"D0, P[], (doc)::{something: {a: apple is included, b: cool.}, over: {here: [{a: apple is included, b: cool.}]}}\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user