jmespath / jmespath/jmespath.jep

Let us select dict values by criteria on their associated keys

Open
#20 8 comments 9 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
10
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Let's say I have

``` python
{
'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:

``` python
[
{ '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 :smile:

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.