Skip to main content
Help us improve Python packaging – donate today!

A JSON serializer for Kombu (and therefore also Celery) that supports encoding objects by defining to_json and from_json methods.

Project Description

Usage
=====

If you want an object to be JSON decodable, you need to define a to_json instance method that returns a dict of json-encodable objects. If you want your object to be encodable, define a from_json class method that takes back that dictionary. You must also use a newstyle class.

An example is below if it would help::

class MyObject(object):

def __init__(self, name):
self._name = name

def to_json(self):
return {'name':self._name}

@classmethod
def from_json(self, obj):
return cls(obj["name"])

Celery Usage
========

ZSON was originally written to allow objects to be passed in Celery. If you want to use zson as your serializer in Celery, you can set this by creating a configuration file and adding::

CELERY_TASK_SERIALIZER = 'zson'
CELERY_RESULT_SERIALIZER = 'zson'
CELERY_ACCEPT_CONTENT = ["zson"]

and then loading this configuration file when you configure your Celery app::

c = celery.Celery('zsearch', backend='amqp', broker='amqp://')
c.config_from_object('celeryconfig')

Release history Release notifications

History Node

1.0.18

History Node

1.0.17

History Node

1.0.16

This version
History Node

1.0.13

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
zson-1.0.13.tar.gz (2.4 kB) Copy SHA256 hash SHA256 Source None Mar 19, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page