Created
January 29, 2019 19:34
-
-
Save jaraco/8167498b51eff44d93d7c5af28a4dd8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__requires__ = ['jsonpickle', 'pymongo'] | |
import json | |
import datetime | |
import jsonpickle | |
import bson.tz_util | |
ob = datetime.datetime( | |
2019, 1, 29, 18, 9, 8, 826000, tzinfo=bson.tz_util.utc) | |
doc = jsonpickle.dumps(ob) | |
jsonpickle.loads(doc) | |
print(doc) | |
unpickler = jsonpickle.unpickler.Unpickler() | |
restored = json.loads(doc, object_hook=unpickler.restore) | |
print(restored) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment