jmespand - Python JMESpath expansion in documents
Purpose
This Python module expands a set of documents (dict
s) with format strings ({expression}
) using JMESPath syntax. The purpose is to use this library in configuration systems to provide
templated configuration sets whose properties can refer to other parts of the configuration (as well as outside scope properties).
Usage
doc1 = yaml.load(...)
>>>{"Hello": "{Value}"}
doc2 = json.load(...)
>>>{"Value": "World"}
root = jmespand.create_root(doc1, doc2)
print(root.expanded())
>>>{"Hello": "World", "Value": "World"}
since all the expressive power of JMESPath is available it is possible to do a lot more advanced things such as predicates, indexing, etc.
Limitations
Currently, expansion is limited to strings only. It is currently not possible to expand entire (sub-)objects.