Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for serializing decimals #187

Merged
merged 1 commit into from
Dec 13, 2016
Merged

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Dec 1, 2016

Lambda supports serializing decimals to json,
so we need to support that as well in chalice local.

Lambda supports serializing decimals to json,
so we need to support that as well in chalice local.
@arundhaj
Copy link
Contributor

arundhaj commented Dec 2, 2016

Can we support datetime serialization as well?

from datetime import datetime

Append the following

if isinstance(obj, decimal.Decimal):
    return float(obj)
elif isinstance(obj, datetime):
    f = '%Y-%m-%d %H:%M:%S'
    return o.strftime(f)

@jamesls
Copy link
Member Author

jamesls commented Dec 13, 2016

This PR is just for chalice local, so I'd prefer to keep parity with what lambda actually does (which doesn't serialize datetimes). Otherwise you'd have behavior where it works in chalice local but fails when you deploy.

@jamesls jamesls merged commit d3d9cc8 into aws:master Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants