https://github.com/youversion/marshmallow_arrow
A Marshmallow Custom Field for Arrow objects.
https://github.com/youversion/marshmallow_arrow
Last synced: 11 months ago
JSON representation
A Marshmallow Custom Field for Arrow objects.
- Host: GitHub
- URL: https://github.com/youversion/marshmallow_arrow
- Owner: youversion
- Created: 2018-01-15T22:38:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-11T04:49:41.000Z (over 6 years ago)
- Last Synced: 2025-05-19T11:52:50.485Z (about 1 year ago)
- Language: Python
- Size: 7.81 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Marshmallow-Arrow
This library provides a Marshmallow field for Arrow objects.
## Usage
Create an ArrowField in your schema:
```python
from marshmallow_arrow import ArrowField
class CalendarEventSchema(Schema):
name = fields.Str()
start_datetime = ArrowField(required=False)
```
ArrowFields are deserialized from isoformatted strings
```python
schema = CalendarEventSchema()
data, _ = schema.load(
{'name': 'Birthday Party', 'start_datetime': arrow.utcnow().isoformat()}
)
# data:
# {'start_datetime': , 'name': u'Birthday Party'}
```
and serialized to isoformatted strings
```python
birthday = arrow.utcnow()
birthday_event = CalendarEvent('Birthday Party', birthday)
schema = CalendarEventSchema()
result = schema.dump(birthday_event)
# result.data
# {u'start_datetime': '2018-01-15T22:23:55.861418+00:00', u'name': u'Birthday Party'}
```