Added multiple object example from PR #1226

This commit is contained in:
Mike Farah 2022-05-27 11:22:10 +10:00
parent 294da55012
commit 439bcaad25
2 changed files with 20 additions and 0 deletions

View File

@ -86,3 +86,16 @@ will output
wrap: frog
```
## Creating yaml from scratch with multiple objects
Running
```bash
yq --null-input '(.a.b = "foo") | (.d.e = "bar")'
```
will output
```yaml
a:
b: foo
d:
e: bar
```

View File

@ -154,6 +154,13 @@ var collectObjectOperatorScenarios = []expressionScenario{
"D0, P[], (!!map)::{wrap: {further: {name: Mike}}}\n",
},
},
{
description: "Creating yaml from scratch with multiple objects",
expression: `(.a.b = "foo") | (.d.e = "bar")`,
expected: []string{
"D0, P[], ()::a:\n b: foo\nd:\n e: bar\n",
},
},
}
func TestCollectObjectOperatorScenarios(t *testing.T) {