Skip to content

onceaweeq/py-jsend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-jsend

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

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

About jsend

http://labs.omniti.com/labs/jsend

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'}}