jmespath / jmespath/jmespath.jep
Let us select dict values by criteria on their associated keys
- 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.