simplejsonobject

A simple python object extension which can easily transform to and from json with compression support


Keywords
json, development, tracker, debug
License
BSD-3-Clause
Install
pip install simplejsonobject==0.1.6

Documentation

simplejsonobject

made-with-python PyPI version PyPI - Downloads PyPI - Implementation pipeline status pylint status coverage report

A simple python object which can easily transform to and from json with compression support

Install

pip install simplejsonobject

Usage

from simplejsonobject import JsonObject


class Sample(JsonObject):
    def __init__(self):
        self.a = "8"
        self.b = 3
        self.c = None

        
def main():
	smp=Sample()
	smp.to_dict() # {"a": tdata, "b": 3, "c": None}
	smp.to_dict_compressed() # {"a": tdata, "b": 3}
	smp.to_json() # '{\n    "a": 8,\n    "b": 3,\n    "c": null\n}'
	smp.to_json_compressed() # '{"a": 8, "b": 3}'
	
	# or you can import from any compressed/notcompressed json/dict
	# all below results same object
	tsmp.from_dict({"a": tdata, "b": 3, "c": None}
	tsmp.from_dict({"a": tdata, "b": 3})
	tsmp.from_json('{\n    "a": "8",\n    "b": 3,\n    "c": null\n}')
	tsmp.from_json('{"a": "8", "b": 3}')


if __name__ == '__main__':
    main()