Skip to main content

Wraps Python json, supporting more Python built-in types.

Project description

PyPI-Status PyPI-Versions Build-Status Codecov LICENCE

morejson is a drop-in replacement for Python’s json that handles additional built-in 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

morejson-1.1.4.tar.gz (21.1 kB view hashes)

Uploaded Source

Built Distribution

morejson-1.1.4-py2.py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page