mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 15:41:22 -07:00
parent
b80854ff50
commit
0f88c71f59
5 changed files with 100 additions and 0 deletions
23
changelogs/fragments/604-lists_mergeby-new-filter.yml
Normal file
23
changelogs/fragments/604-lists_mergeby-new-filter.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
minor_changes:
|
||||
- |
|
||||
A new filter ``lists_mergeby`` to merge two lists of dictionaries by an attribute.
|
||||
For example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
[{'n': 'n1', 'p1': 'A', 'p2': 'F'},
|
||||
{'n': 'n2', 'p2': 'B'}] | community.general.lists_mergeby(
|
||||
[{'n': 'n1', 'p1': 'C'},
|
||||
{'n': 'n2', 'p2': 'D'},
|
||||
{'n': 'n3', 'p3': 'E'}], 'n') | list
|
||||
|
||||
evaluates to
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
[{'n': 'n1', 'p1': 'C', 'p2': 'F'},
|
||||
{'n': 'n2', 'p2': 'D'},
|
||||
{'n': 'n3', 'p3': 'E'}]
|
||||
|
||||
(https://github.com/ansible-collections/community.general/pull/604).
|
Loading…
Add table
Add a link
Reference in a new issue