mirror of
https://github.com/mikefarah/yq.git
synced 2025-02-04 18:45:09 +00:00
Better formatting of merge arrays example
This commit is contained in:
parent
418bd1a806
commit
f5f148cadb
@ -262,8 +262,9 @@ And another sample another.yml file of:
|
||||
```
|
||||
then
|
||||
```bash
|
||||
yq eval-all '((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
||||
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
||||
yq eval-all '
|
||||
((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
||||
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
||||
' sample.yml another.yml
|
||||
```
|
||||
will output
|
||||
|
@ -37,8 +37,9 @@ To use this, you will need to update '.[]' to be the expression to your array (e
|
||||
Thanks Kev from [stackoverflow](https://stackoverflow.com/a/70109529/1168223)
|
||||
`
|
||||
|
||||
var mergeExpression = `((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
||||
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
||||
var mergeExpression = `
|
||||
((.[] | {.a: .}) as $item ireduce ({}; . * $item )) as $uniqueMap
|
||||
| ( $uniqueMap | to_entries | .[]) as $item ireduce([]; . + $item.value)
|
||||
`
|
||||
|
||||
var docWithHeader = `# here
|
||||
|
Loading…
Reference in New Issue
Block a user