Extended JSON encoder for Python data structures
Project description
json-ext-encoder
Extended JSON encoder for Python data structures.
A subclass of JSONEncoder, it handles these additional types:
datetime.datetime
— a string of the formYYYY-MM-DDTHH:mm:ss.sssZ
orYYYY-MM-DDTHH:mm:ss.sss+HH:MM
as defined in ECMA-262.datetime.date
— a string of the formYYYY-MM-DD
as defined in ECMA-262.datetime.time
— a string of the formHH:MM:ss.sss
as defined in ECMA-262.datetime.timedelta
- a string representing a duration as defined in ISO-8601. For example,timedelta(days=1, hours=2, seconds=3.4)
is represented asP1DT02H00M03.400000S
.decimal.Decimal
,uuid.UUID
— a string representation of the object.enum.Enum
— a.value
property of enum member.
Installation
$ pip install json-ext-encoder
Usage
import json
from json_ext_encoder import JSONEncoder
json.dumps({...}, cls=JSONEncoder)
Testing and linting
For testing and linting install tox:
$ pip install tox
...and run:
$ tox
License
json-ext-encoder
is licensed under the MIT license. See the license file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json-ext-encoder-0.1.0.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for json_ext_encoder-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1bbc78b8a321ba28d5d018d7170178fad3b6b8f3c03c2ca3bcccf4fa20cbd75 |
|
MD5 | 9d2adc0cea15359d568a45f374edfec8 |
|
BLAKE2b-256 | 99948e42341a77a3f7dff6a8cf60254c578ed9386e60d31dbc26d16a995503b4 |