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.2.tar.gz
(2.7 kB
view hashes)
Built Distribution
Close
Hashes for json_default-0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 986d9db82208689cd5d0ec1ee3672317fbd51f83419c93222378192cdf690568 |
|
MD5 | 2bad3974e5dd7f64c898ae4daa39f49f |
|
BLAKE2b-256 | 2373e49f40041bf41d510e32bedaae1b2646cada083cbda9283d8cb2f1e37d70 |