ezjson

Ezjson (means easy json) is a simple python module to encode and decode json.


License
BSD-3-Clause
Install
pip install ezjson==1.0

Documentation

ezjson

Ezjson (means easy json) is a simple python module to encode and decode json. The reason by which I did this module, is because i dont like the way as anothers modules, works . There is some python objects (like datetime.date) that isn't JSON serializable and it often generates errors. Encode and decode JSON it should be an simple task, like in PHP way.

##Usage

import ezjson as json

#Encoding
dumped = json.dump(a_object)
#or
encoded = json.encode(a_object)

#------------------------------------

#Decoding
loaded = json.load(dumped) 
#or
decoded = json.decode(encoded)

##Functions dump(python_data, date_format='%Y/%m/%d', max_depth=3)

  • python_data: the python data to be converted to json.

  • date_format: pattern for formatting dates. Default pattern is %Y/%m/%d.

  • max_depth: refer to how deep the recursion can reach (object inside object, inside object, inside...). Default is 3.

    Returns a unicode of the encoded json.

encode(python_data, date_format='%Y/%m/%d', max_depth=3)

Alias to dump function

load(json, to_object=False)

  • json: The json that will be loaded as a python data

  • to_object: If True returns a python object.

    Returns a dict by default or a python object if to_object is True.

decode(json, to_object=False)

Alias to load function

##Installation

$ pip install ezjson

or download/clone the package and

$ python setup install