Skip to content

Instantly share code, notes, and snippets.

@tokibito
Created November 12, 2015 10:59
Show Gist options
  • Save tokibito/8f8e92fa4a224bf8c23a to your computer and use it in GitHub Desktop.
Save tokibito/8f8e92fa4a224bf8c23a to your computer and use it in GitHub Desktop.
bpmappers example
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