Better add documentation

This commit is contained in:
Mike Farah 2021-01-11 15:52:06 +11:00
parent 578f2c27f9
commit 461661112c
2 changed files with 8 additions and 12 deletions

View File

@ -67,23 +67,19 @@ will output
- 2
```
## Add object to array
## Add new object to array
Given a sample.yml file of:
```yaml
a:
- 1
- 2
c:
cat: meow
- dog: woof
```
then
```bash
yq eval '.a + .c' sample.yml
yq eval '.a + {"cat": "meow"}' sample.yml
```
will output
```yaml
- 1
- 2
- dog: woof
- cat: meow
```

View File

@ -38,11 +38,11 @@ var addOperatorScenarios = []expressionScenario{
},
},
{
description: "Add object to array",
document: `{a: [1,2], c: {cat: meow}}`,
expression: `.a + .c`,
description: "Add new object to array",
document: `a: [{dog: woof}]`,
expression: `.a + {"cat": "meow"}`,
expected: []string{
"D0, P[a], (!!seq)::[1, 2, {cat: meow}]\n",
"D0, P[a], (!!seq)::[{dog: woof}, {cat: meow}]\n",
},
},
{