This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
  • json encoder uses singledispatch pattern instead of JSONEncoder class overwrites.
  • No more json.dumps(data, cls=MyJSONEncoder) everywhere.
  • Comes with default serialization for time, date, datetime, UUID and Decimal
  • Easy to use, easy to change serialization behaviour
  • Not tight to any json implementation json, simplejson, ujson
  • It parse json float numbers into Decimal objects to prevent python float precision issues.

Installation

$ pip install json-encoder

Quick start

  • Use “json_encoder.json” instead of default python json:

    from json_encoder import json
    
    result = json.dumps(data)
    

Configuration

  • Chose json implementation:

    # simplejson library is used as default json implementation if present
    # otherwise standard python json implementation is used
    # to use other json implementation globally, do:
    
    import ujson
    from json_encoder import use_json_library
    
    use_json_library(ujson)
    
  • To change json implementation for concrete call do:

    from json_encoder import json
    import simplejson
    
    result = json.dumps(data, json=simplejson)
    
  • To make your object JSON serializable do:

    # example how to make python fraction object json serializable
    
    from fractions import Fraction
    from json_encoder.encoder import json_encoder
    
    @json_encoder.register(Fraction)
    def encode_fraction(obj):
        return '{}/{}'.format(obj.numerator, obj.denominator)
    
  • To overwrite JSON serializer behaviour defined in json_encoder.encoder:

    from uuid import UUID
    from six import text_type
    from json_encoder.encoder import json_encoder
    
    @json_encoder.register(UUID)
    def encode_uuid(obj):
        return text_type(obj).replace('-', '')
    

Requirements

Release History

Release History

0.4.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
json_encoder-0.4.4-py2.py3-none-any.whl (7.4 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Sep 18, 2016
json-encoder-0.4.4.tar.gz (5.2 kB) Copy SHA256 Checksum SHA256 Source Sep 16, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting