Skip to content

Let us select dict values by criteria on their associated keys #20

Description

@copumpkin

Let's say I have

{
  'bark': 'oink',
  'foo1': 'foo',
  'foo2': 'woof',
  'foo3': 'meow'
}

and want to select all values for which keys start with "foo". I tried for a bit to get JMESPath to get me ['foo', 'woof', 'meow'] but was unsuccessful. I don't know if it's impossible, but I was thinking that a simple approach might be a built-in function called pivot/reify/mappings (I'm bad at naming) that transforms the above into a list of Key/Value mappings, so:

[
  { 'Key': 'bark', 'Value': 'oink' },
  { 'Key': 'foo1', 'Value': 'foo' },
  { 'Key': 'foo2', 'Value': 'woof' },
  { 'Key': 'foo3', 'Value': 'meow' }
]

which seems far easier to deal with. I'm open to other approaches to achieving the same goal, of course 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions