jmespath / jmespath/jmespath.py
Create object from a key-value list
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 212
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
First and foremost, thanks in advance for sharing JMESPath. It is very powerful especially it is used in ansible, which makes it very simple when querying or creating specified data.
Recentlly, I faced a challenge that when I queried a object array, I want to extract some attributes from it and make these attributes to build a new object. Consider the case of a JSON document like:
[
{"name":"instance-1","ip":"10.0.0.1"},
{"name":"instance-2","ip":"10.0.0.2"},
{"name":"instance-3","ip":"10.0.0.3"}
]
Now, I want to build an object(Because I want to call some other modue in ansible which needs a new format) :
{
"instance-1":"10.0.0.1",
"instance-2":"10.0.0.2",
"instance-3":"10.0.0.3",
}
How do I do ?
Thansk very much!!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.