glom
glom copied to clipboard
☄️ Python's nested data operator (and CLI), for all your declarative restructuring needs. Got data? Glom it! ☄️
From https://glom.readthedocs.io/en/latest/snippets.html glom({1:2, 2:3}, Call(dict, args=T.items()) >> from glom import glom, T, Call >>> glom({1:2, 2:3}, Call(dict, args=T.items())) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.6/dist-packages/glom/core.py",...
I'm dealing with some nested lists and would like to do something like: ```bash >>> target = { ... 'f1': 'v', ... 'f2': [{ ... 'f3': 'a', ... 'f4': 0,...
Now that #32 has added scopes to glom, it's possible to do multi-target glomming. I think the next frontier in this area is enabling relative paths. The obvious analogy is...
I'm looking through documentation and I can't seem to find coverage for this vital feature for any tree parsing. Is it possible to select __any descendant__ with glom? Equivalent to...
Hi! I am using `glom` as a part of my REST API, it is used to serialize and deserialize requests when API does not 100% match existing objects. And I...
does it make sense to have a Spec-shaped data structure attached to exceptions e.g. `{'a': { 'b': 'error'} }` similar to https://www.django-rest-framework.org/api-guide/exceptions/ ``` {"amount": ["A valid integer is required."], "description":...
Sometimes we need to move data from key to key. ```python def format_data(webhook_data): return glom(webhook_data, ( Assign('object_attributes.project', Spec('project')), )) ``` And then using it: ```python webhook_data = {'project': {'uid': 1},...
Related to https://github.com/mahmoud/glom/issues/81 The same problem I have with other attributes in dicts that must be renamed before actually working with them. ```python def tranform_data(webhook): return glom(webhook_data, ( Assign('project.id', Spec('project.uid')),...
`glom` is great, thanks for making it! This PR makes the error message more informative when your target is a list and your spec is not. Currently when target is...
Each one of those two spec work separately. ```python from glom import Spec, T, glom d = {'a': [1, {'b': 2}, 3], 'c': {'d': [4, 5]}} spec = Spec(T['a'][1]['b'], T['c']['d'][1])...