Skip to main content

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

Project description

PyPI-Status PyPI-Versions Build-Status LICENCE

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

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.1.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

morejson-1.1.1-py2.py3-none-any.whl (6.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file morejson-1.1.1.tar.gz.

File metadata

  • Download URL: morejson-1.1.1.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for morejson-1.1.1.tar.gz
Algorithm Hash digest
SHA256 dc6244843f3178e8be5513be04be8557b7060424e6dca9a6d61483f847cada6d
MD5 8702f33f5aaa66cf82fc9ebd9bc226fb
BLAKE2b-256 d0e2a7280a20221267cca37173570f437291b4d8f8c3453a8edc7d84a59cbfa3

See more details on using hashes here.

Provenance

File details

Details for the file morejson-1.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for morejson-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 25233e759f6ce0ed4fe8536f5192de6d40215de01c17b58001c6b4152fe00a74
MD5 41daf3213e4f430d6e8ef7d322c94611
BLAKE2b-256 6b0d1f76350e24f56cc4645f3b1a57ad7f3bd9b228935d68e51f902014dcb0f0

See more details on using hashes here.

Provenance

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