Code Monkey home page Code Monkey logo

morejson's Introduction

morejson

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   Contributing

Package author and current maintainer is Shay Palachy ([email protected]); You are more than welcome to approach him for help. Contributions are very welcomed.

4.1   Installing for development

Clone:

git clone [email protected]:shaypal5/morejson.git

Install in development mode with test dependencies:

cd morejson
pip install -e ".[test]"

4.2   Running the tests

To run the tests, use:

nosetests --cover-erase --with-coverage --cover-package=morejson -d

4.3   Adding documentation

This project is documented using the numpy docstring conventions, which were chosen as they are perhaps the most widely-spread conventions that are both supported by common tools such as Sphinx and result in human-readable docstrings (in my personal opinion, of course). When documenting code you add to this project, please follow these conventions.

5   Credits

Created by Shay Palachy ([email protected]).

Inspired by a great Github gist by abhinav-upadhyay: https://gist.github.com/abhinav-upadhyay/5300137

morejson's People

Contributors

preston-landers avatar shaypal5 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.