Skip to main content

A JSON serializer for Python

Project description

# Objackson
This is a JSON serializer for Python that supports deep serialization of objects and full reconstruction of object structure on deserialization.
Circular references are supported too.

# How to install
Install latest version of Objackson from PyPI:

python3 -m pip install objackson

# How to use

from objackson import obj2json, json2obj

class MyClass:

def __init__(self, x=0, y=0):
self.__x = x
self.__y = y

@property
def x(self):
return self.__x

@property
def y(self):
return self.__y

def __eq__(self, obj)
return self.x == obj.x and self.y = obj.y

def main():
obj1 = TestClass(2, 3)
json = obj2json(obj1)
obj2 = json2obj(json)

# obj2 is a copy of obj1. Test it:
if obj1 == obj2:
print("SUCCESS")
else:
print("FAIL")

if __name__ == "__main__"
main()


For a class to be serializable, it must have a constructor that allows zero-arguments initialization.

Project details


Download files

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

Source Distribution

Objackson-1.0.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

Objackson-1.0.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file Objackson-1.0.1.tar.gz.

File metadata

  • Download URL: Objackson-1.0.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for Objackson-1.0.1.tar.gz
Algorithm Hash digest
SHA256 fd54f5332bfcaec88f33b3f9d2a2450d0073d75ca55e915c6cbbeee580785f73
MD5 0180083fac19b0051ffdd37db51b1f97
BLAKE2b-256 a114e34f33e34d4c92a154664b40c2270417ce0801ead2ae6c06a24a66db37f0

See more details on using hashes here.

File details

Details for the file Objackson-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: Objackson-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for Objackson-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec96db4024fa8864aabb60364557be40d4d79637f56c688fad2bd191cc4d6bab
MD5 794b3a1322c24978682d00fd99b5f6df
BLAKE2b-256 250ce0f9c09b929a3b9df98c9410df797b642b8e47014c009a0bc07ad0531d4c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page