Created
November 12, 2015 10:59
-
-
Save tokibito/8f8e92fa4a224bf8c23a to your computer and use it in GitHub Desktop.
bpmappers example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bpmappers import * | |
class ObjectMapper(Mapper): | |
key = RawField() | |
class ObjectListMapper(Mapper): | |
member = NonKeyListDelegateField(ObjectMapper) | |
def filter_member(self): | |
return self.data | |
def as_list(self): | |
return self.as_dict()['member'] | |
data = [ | |
{'key': 'val1'}, | |
{'key': 'val2'}, | |
] | |
print(ObjectListMapper(data).as_list()) | |
""" | |
$ python main.py | |
[{'key': 'val1'}, {'key': 'val2'}] | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment