Objackson


NameObjackson JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/sv-giampa/Objackson
SummaryA JSON serializer for Python
upload_time2024-02-14 22:23:26
maintainer
docs_urlNone
author'Salvatore Giampà'
requires_python>=3.8.0
licenseApache License version 2.0
keywords json serializer deserializer serialization deserialization object
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sv-giampa/Objackson",
    "name": "Objackson",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": "",
    "keywords": "json,serializer,deserializer,serialization,deserialization,object",
    "author": "'Salvatore Giamp\u00e0'",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a1/14/e34f33e34d4c92a154664b40c2270417ce0801ead2ae6c06a24a66db37f0/Objackson-1.0.1.tar.gz",
    "platform": null,
    "description": "# Objackson\nThis is a JSON serializer for Python that supports deep serialization of objects and full reconstruction of object structure on deserialization.\nCircular references are supported too.\n\n# How to install\nInstall latest version of Objackson from PyPI:\n\n    python3 -m pip install objackson\n\n# How to use\n\n    from objackson import obj2json, json2obj\n\n    class MyClass:\n\n        def __init__(self, x=0, y=0):\n            self.__x = x\n            self.__y = y\n        \n        @property\n        def x(self):\n            return self.__x\n\n        @property\n        def y(self):\n            return self.__y\n\n        def __eq__(self, obj)\n            return self.x == obj.x and self.y = obj.y\n        \n    def main():\n        obj1 = TestClass(2, 3)\n        json = obj2json(obj1)\n        obj2 = json2obj(json)\n\n        # obj2 is a copy of obj1. Test it:\n        if obj1 == obj2:\n            print(\"SUCCESS\")\n        else:\n            print(\"FAIL\")\n\n    if __name__ == \"__main__\"\n        main()\n\n\nFor a class to be serializable, it must have a constructor that allows zero-arguments initialization.\n",
    "bugtrack_url": null,
    "license": "Apache License version 2.0",
    "summary": "A JSON serializer for Python",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/sv-giampa/Objackson"
    },
    "split_keywords": [
        "json",
        "serializer",
        "deserializer",
        "serialization",
        "deserialization",
        "object"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "250ce0f9c09b929a3b9df98c9410df797b642b8e47014c009a0bc07ad0531d4c",
                "md5": "794b3a1322c24978682d00fd99b5f6df",
                "sha256": "ec96db4024fa8864aabb60364557be40d4d79637f56c688fad2bd191cc4d6bab"
            },
            "downloads": -1,
            "filename": "Objackson-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "794b3a1322c24978682d00fd99b5f6df",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 9167,
            "upload_time": "2024-02-14T22:23:25",
            "upload_time_iso_8601": "2024-02-14T22:23:25.556033Z",
            "url": "https://files.pythonhosted.org/packages/25/0c/e0f9c09b929a3b9df98c9410df797b642b8e47014c009a0bc07ad0531d4c/Objackson-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a114e34f33e34d4c92a154664b40c2270417ce0801ead2ae6c06a24a66db37f0",
                "md5": "0180083fac19b0051ffdd37db51b1f97",
                "sha256": "fd54f5332bfcaec88f33b3f9d2a2450d0073d75ca55e915c6cbbeee580785f73"
            },
            "downloads": -1,
            "filename": "Objackson-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "0180083fac19b0051ffdd37db51b1f97",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 7636,
            "upload_time": "2024-02-14T22:23:26",
            "upload_time_iso_8601": "2024-02-14T22:23:26.805219Z",
            "url": "https://files.pythonhosted.org/packages/a1/14/e34f33e34d4c92a154664b40c2270417ce0801ead2ae6c06a24a66db37f0/Objackson-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-14 22:23:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sv-giampa",
    "github_project": "Objackson",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "objackson"
}
        
Elapsed time: 3.33494s