mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-23 22:25:42 +00:00
Added space example to docs
This commit is contained in:
parent
dd17f072cf
commit
e02ad4d7e8
@ -48,6 +48,22 @@ will output
|
|||||||
frog
|
frog
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Keys with spaces
|
||||||
|
Use quotes with brackets around path elements with special characters
|
||||||
|
|
||||||
|
Given a sample.yml file of:
|
||||||
|
```yaml
|
||||||
|
"red rabbit": frog
|
||||||
|
```
|
||||||
|
then
|
||||||
|
```bash
|
||||||
|
yq eval '.["red rabbit"]' sample.yml
|
||||||
|
```
|
||||||
|
will output
|
||||||
|
```yaml
|
||||||
|
frog
|
||||||
|
```
|
||||||
|
|
||||||
## Dynamic keys
|
## Dynamic keys
|
||||||
Expressions within [] can be used to dynamically lookup / calculate keys
|
Expressions within [] can be used to dynamically lookup / calculate keys
|
||||||
|
|
||||||
|
@ -54,6 +54,15 @@ var traversePathOperatorScenarios = []expressionScenario{
|
|||||||
"D0, P[{}], (!!str)::frog\n",
|
"D0, P[{}], (!!str)::frog\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "Keys with spaces",
|
||||||
|
subdescription: "Use quotes with brackets around path elements with special characters",
|
||||||
|
document: `{"red rabbit": frog}`,
|
||||||
|
expression: `.["red rabbit"]`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[red rabbit], (!!str)::frog\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
skipDoc: true,
|
skipDoc: true,
|
||||||
document: `{"flying fox": frog}`,
|
document: `{"flying fox": frog}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user