mirror of
https://github.com/kennethreitz/tablib.git
synced 2026-06-05 15:00:19 +00:00
Merge pull request #186 from hdzierz/develop
Added a mechanism to avoid datetime.datetime issues when serializing dat...
This commit is contained in:
@@ -13,14 +13,18 @@ title = 'json'
|
|||||||
extensions = ('json', 'jsn')
|
extensions = ('json', 'jsn')
|
||||||
|
|
||||||
|
|
||||||
|
def date_handler(obj):
|
||||||
|
return obj.isoformat() if hasattr(obj, 'isoformat') else obj
|
||||||
|
|
||||||
|
|
||||||
def export_set(dataset):
|
def export_set(dataset):
|
||||||
"""Returns JSON representation of Dataset."""
|
"""Returns JSON representation of Dataset."""
|
||||||
return json.dumps(dataset.dict)
|
return json.dumps(dataset.dict, default=date_handler)
|
||||||
|
|
||||||
|
|
||||||
def export_book(databook):
|
def export_book(databook):
|
||||||
"""Returns JSON representation of Databook."""
|
"""Returns JSON representation of Databook."""
|
||||||
return json.dumps(databook._package())
|
return json.dumps(databook._package(), default=date_handler)
|
||||||
|
|
||||||
|
|
||||||
def import_set(dset, in_stream):
|
def import_set(dset, in_stream):
|
||||||
|
|||||||
Reference in New Issue
Block a user