List comprehension way:
[item.json() for item in ItemObject.query.all()]
Lambda way:
list(map(lambda x: x.json(), ItemObject.query.all()))
It is more pythonic to do it via list comprehension, but people familiar with functional languages might have easier time understanding lambda way
No comments:
Post a Comment