Extensible default function for JSONEncoder
Project description
Overview
Whilst looking about to see if anyone had proposed a __json__ protocol for Python, I found this article and it struck me as so simple and obviously right.
So, I decided to provide a lib to make it easier for everyone.
Usage
Just pass json_default.default as the default function when calling json.dump(s).
import json
from json_default import default
...
return json.dumps(mydata, default=default)
If you have more types you want to define serialisation for, just add them:
from json_default import default
@default.register(mytype):
def _(obj):
...
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_default-0.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for json_default-0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a249bd22b3264416c2b8404b737814e263464decd8793b10fd3a014234a6c30a |
|
MD5 | c4b8472e6a0b1bb51d2b5c9f7d093d28 |
|
BLAKE2b-256 | 1f9143f307966cd46f9fa3673dde2269444d53dee22418770f1d9e7ba813a02d |