Metadata-Version: 2.1
Name: datetimejson
Version: 0.1.1
Summary: Read and write json files with datetime objects
Home-page: https://github.com/boileaum/datetimejson
Author: Matthieu Boileau
Author-email: matthieu.boileau@math.unistra.fr
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# Datetime JSON

[![Github action badge](https://github.com/boileaum/datetimejson/actions/workflows/test.yml/badge.svg)](https://github.com/boileaum/datetimejson/actions)

Serialize and deserialize datetime objects to and from JSON.

This package provides:

* 4 functions that wrap the `json` module:
    - `load/loads` - Deserialize a JSON string containing datetime objects
    - `dump/dumps` - Serialize python object containting datetime objects to JSON

* two classes that wrap derived from `json.JSONEncoder` and `json.JSONDecoder`:
    - `JSONEncoder` - Serialize a datetime object to JSON
    - `JSONDecoder` - Deserialize a JSON string to a datetime object

Usage:

```python
>>> from datetimejson import dumps, loads
>>> from datetime import datetime
>>> now = datetime.now()
>>> print(now)
2023-02-13 11:27:56.687439
>>> json_string = dumps(now)
>>> print(json_string)
{"__type__": "datetime", "year": 2023, "month": 2, "day": 13, "hour": 11, "minute": 27, "second": 56, "microsecond": 687439}
>>> print(loads(json_string))
2023-02-13 11:27:56.687439
>>> 
```

Original code by [@ApptuitAI](https://github.com/ApptuitAI): <https://gist.github.com/abhinav-upadhyay/5300137>
