Open ChenXiaoTemp opened 6 years ago
Use case:
Given
[ {"type":"large","ip":"10.0.0.1"}, {"type":"large","ip":"10.0.0.2"}, {"type":"small","ip":"10.0.0.3"} ] I'd like to create:
{ "large": [{"type":"large","ip":"10.0.0.1"},{"type":"large","ip":"10.0.0.2"}], "small":[{"type":"small","ip":"10.0.0.3"}] }
Is there any query expression to do it?
Thanks very much.
if you know the groups ahead of time try: {large: [? type == `large` ], small: [? type == `small` ]
{large: [? type == `large` ], small: [? type == `small` ]
The group_by() function is currently being proposed for inclusion in the next version of JMESPath Community.
group_by()
Use case:
Given
[ {"type":"large","ip":"10.0.0.1"}, {"type":"large","ip":"10.0.0.2"}, {"type":"small","ip":"10.0.0.3"} ] I'd like to create:
{ "large": [{"type":"large","ip":"10.0.0.1"},{"type":"large","ip":"10.0.0.2"}], "small":[{"type":"small","ip":"10.0.0.3"}] }
Is there any query expression to do it?
Thanks very much.