Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

A python jsend library

Project description

python jsend pypi: https://pypi.python.org/pypi/pyjsend/

https://travis-ci.org/onceaweeq/py-jsend.svg?branch=master https://badge.fury.io/py/pyjsend.svg

Install

pip install pyjsend

Usage

import module:

>>> import jsend

success:

>>> jsend.success({'key': 'value'})
{'status': 'success', 'data': {'key': 'value'}}

fail:

>>> jsend.fail({'key': 'value'})
{'status': 'fail', 'data': {'key': 'value'}}

error:

>>> jsend.error('message')
{'status': 'error', 'message': 'message'}

is success:

>>> jsend.is_success({'status':'success'})
True

is fail:

>>> jsend.is_fail({'status':'fail'})
True

is error:

>>> jsend.is_error({'status':'error'})
True

to json string and load jsend string:

>>> jsend.success({'key': 'value'}).stringify()
'{"status": "success", "data": {"key": "value"}}'

>>> jsend.loads(jsend.success({'key': 'value'}).stringify())
{u'status': u'success', u'data': {u'key': u'value'}}

Download files

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

Files for pyjsend, version 0.2.2
Filename, size File type Python version Upload date Hashes
Filename, size pyjsend-0.2.2-py2.py3-none-any.whl (3.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page