datetimejson-0.1.7
توضیحات
Read and write json files with datetime objects
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | datetimejson-0.1.7 |
| نام | datetimejson |
| نسخه کتابخانه | 0.1.7 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | Matthieu Boileau <matthieu.boileau@math.unistra.fr> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/datetimejson/ |
| مجوز | MIT |
# Datetime JSON
[](https://github.com/boileaum/datetimejson/actions)
Serialize and deserialize datetime objects to and from JSON.
This package provides:
* 4 functions that wrap the corresponding functions of the [`json`](https://docs.python.org/fr/3/library/json.html) module:
- `load/loads` - Deserialize a JSON string containing datetime objects
- `dump/dumps` - Serialize python object containting datetime objects to JSON
* two classes derived respectively from `json.JSONEncoder` and `json.JSONDecoder`:
- `DateTimeEncoder` - Serialize a datetime object to JSON
- `DateTimeDecoder` - Deserialize a JSON string to a datetime object
## Installation
```bash
pip install datetimejson
```
## Usage
Just replace `json` import by `datetimejson` in your code:
```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>
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl datetimejson-0.1.7:
pip install datetimejson-0.1.7.whl
نصب پکیج tar.gz datetimejson-0.1.7:
pip install datetimejson-0.1.7.tar.gz