Skip to content

Latest commit

 

History

History
70 lines (42 loc) · 1.49 KB

json_datetime.rst

File metadata and controls

70 lines (42 loc) · 1.49 KB

jnrbase.json_datetime

json_datetime

Functions

json_serialise

Implemented with functools.singledispatch.

datetime_serialise(__o: datetime.datetime) -> str

Specialisation of json_serialise for datetime.datetime objects.

timedelta_serialise(__o: datetime.timedelta) -> str

Specialisation of json_serialise for datetime.timedelta objects.

json_using_iso8601

dump(…)

Simple json.dump wrapper using json_serialise.

dumps(…)

Simple json.dumps wrapper using json_serialise.

load(…)

Simple json.load wrapper using json_using_iso8601.

loads(…)

Simple json.loads wrapper using json_using_iso8601.

Examples

from datetime import datetime, timezone

from jnrbase.json_datetime import dumps, loads

>>> data = {'test': datetime(2016, 11, 30, 18, 35, tzinfo=timezone.utc)} >>> dumps(data, indent=None) '{"test": "2016-11-30T18:35:00Z"}' >>> loads(dumps(data, indent=None)) == data True

KT datetime json serialiser