morejson is a drop-in replacement for Python's json module that handles additional built-in and standard library Python types.
Project description
morejson is a drop-in replacement for Python’s json module that handles additional built-in and standard library Python types.
import morejson as json
import datetime
json.dumps({'now': datetime.datetime.now()})
json.dumps({'set': set([1,2]), 'complex': complex(32, -4)})
1 Installation
Install morejson with:
pip install morejson
2 Use
morejson implements the exact same API as Python’s built-in json module; the dump, dumps, load and loads methods wrap around their json counterparts without changing their interface, while any other function or attribute is left unchanged.
You can use any argument of these methods, including default, cls and object_hook; morejson will wrap around any kind of custom behaviour you provide, giving it priority over morejson’s encoding or decoding, and allowing you to use it with any custom JSON encoding/decoding code you have.
3 Supported Types
3.1 Built-in Types
set
frozenset
complex
3.2 datetime module types
date
time
datetime
timedelta
timezone
4 Credits
Created by Shay Palachy (shay.palachy@gmail.com).
Inspired by a great Github gist by abhinav-upadhyay: https://gist.github.com/abhinav-upadhyay/5300137
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
Built Distribution
File details
Details for the file morejson-1.0.9.tar.gz
.
File metadata
- Download URL: morejson-1.0.9.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dfb7519912f2ef152f2982a7e754046865ed92ea439cf4c563da6ec03e2253e |
|
MD5 | ff1595a2a9863ffb523126c3ac9bf532 |
|
BLAKE2b-256 | 12d378900ef185f8c26b8da450c1ea3bd7d176c86eb2a9000aa57c722c9f216c |
Provenance
File details
Details for the file morejson-1.0.9-py2.py3-none-any.whl
.
File metadata
- Download URL: morejson-1.0.9-py2.py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f05a4c4398712932935754c8776954f8dfbf62d6e8587792753382c7e181b17 |
|
MD5 | 488db88c4836b9d6cd80c05a098f5d61 |
|
BLAKE2b-256 | ba59b6b791ac891bbf3a34a715d9ba315a6f40f297b2d85292253d8c61a34648 |