mirror of
https://github.com/mikefarah/yq.git
synced 2025-01-23 14:16:10 +00:00
Fixing special character example
This commit is contained in:
parent
30027a8cf4
commit
a5ddbca97f
@ -33,7 +33,7 @@ c: banana
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Special characters
|
## Special characters
|
||||||
Use quotes around path elements with special characters
|
Use quotes with brackets around path elements with special characters
|
||||||
|
|
||||||
Given a sample.yml file of:
|
Given a sample.yml file of:
|
||||||
```yaml
|
```yaml
|
||||||
@ -41,7 +41,7 @@ Given a sample.yml file of:
|
|||||||
```
|
```
|
||||||
then
|
then
|
||||||
```bash
|
```bash
|
||||||
yq eval '."{}"' sample.yml
|
yq eval '.["{}"]' sample.yml
|
||||||
```
|
```
|
||||||
will output
|
will output
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -47,13 +47,21 @@ var traversePathOperatorScenarios = []expressionScenario{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Special characters",
|
description: "Special characters",
|
||||||
subdescription: "Use quotes around path elements with special characters",
|
subdescription: "Use quotes with brackets around path elements with special characters",
|
||||||
document: `{"{}": frog}`,
|
document: `{"{}": frog}`,
|
||||||
expression: `."{}"`,
|
expression: `.["{}"]`,
|
||||||
expected: []string{
|
expected: []string{
|
||||||
"D0, P[{}], (!!str)::frog\n",
|
"D0, P[{}], (!!str)::frog\n",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
skipDoc: true,
|
||||||
|
document: `{"flying fox": frog}`,
|
||||||
|
expression: `.["flying fox"]`,
|
||||||
|
expected: []string{
|
||||||
|
"D0, P[flying fox], (!!str)::frog\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
description: "Dynamic keys",
|
description: "Dynamic keys",
|
||||||
subdescription: `Expressions within [] can be used to dynamically lookup / calculate keys`,
|
subdescription: `Expressions within [] can be used to dynamically lookup / calculate keys`,
|
||||||
|
Loading…
Reference in New Issue
Block a user