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

Fix json datetime encoding exception #263

Merged
merged 4 commits into from
Apr 23, 2017

Conversation

cehbrecht
Copy link
Collaborator

Overview

the json dump method of WPSRequest was not able to handle LiteralInput with datetime objects. See error message below.

This patch extends the json encoder to handle datetime objects. Tests are added for WPSRequest and LiteralInput to check json dump/load with datetime objects.

Additional Information

Error message:

 File "/home/pingu/.conda/envs/malleefowl/lib/python2.7/site-packages/pywps/app/WPSRequest.py", line 320, in json
    return json.dumps(obj, allow_nan=False)
  File "/home/pingu/.conda/envs/malleefowl/lib/python2.7/json/__init__.py", line 251, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/home/pingu/.conda/envs/malleefowl/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/home/pingu/.conda/envs/malleefowl/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/home/pingu/.conda/envs/malleefowl/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: datetime.datetime(2005, 12, 31, 0, 0) is not JSON serializable

Contribution Agreement

(as per https://github.com/geopython/pywps/blob/master/CONTRIBUTING.rst#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to PyWPS. I confirm that my contributions to PyWPS will be compatible with the PyWPS license guidelines at the time of contribution.
  • I have already previously agreed to the PyWPS Contributions and Licensing Guidelines

@jachym jachym merged commit 03a766f into geopython:develop Apr 23, 2017
@cehbrecht cehbrecht deleted the fix-json-datetime branch April 28, 2017 12:52
@jachym jachym added this to the 4.2.0 milestone Jun 4, 2017
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