{ "info": { "author": "Matthew Reid", "author_email": "matt@nomadic-recording.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development" ], "description": "|Build Status| |Coverage Status|\r\n\r\njson-object-factory\r\n===================\r\n\r\nSimplifies building custom encoders and object-hooks for Python's\r\ndefault JSON implementation.\r\n\r\nInstallation\r\n------------\r\n\r\n::\r\n\r\n $ pip install json-object-factory\r\n\r\nUsage\r\n-----\r\n\r\nAdd encoders and decoders to the registry:\r\n\r\n.. code:: python\r\n\r\n import jsonfactory\r\n\r\n class MyJsonHandler(object):\r\n def encode(self, o):\r\n if isinstance(o, MyCustomClass):\r\n return o.serialize()\r\n return None\r\n\r\n def decode(self, d):\r\n if 'some_custom_key' in d:\r\n return MyCustomClass(**d)\r\n return d\r\n\r\n jsonfactory.Registry.register(MyJsonHandler)\r\n\r\nOr use the included decorators:\r\n\r\n.. code:: python\r\n\r\n @jsonfactory.register\r\n class MyOtherJsonHandler(object):\r\n ...\r\n\r\n @jsonfactory.encoder\r\n def an_encoder_function(o):\r\n ...\r\n\r\n @jsonfactory.decoder\r\n def a_decoder_function(d):\r\n ...\r\n\r\nThen use the module's ``dumps`` and ``loads`` functions:\r\n\r\n.. code:: python\r\n\r\n json_str = jsonfactory.dumps(obj_dict, indent=2)\r\n\r\n new_obj_dict = jsonfactory.loads(json_str)\r\n\r\nNotes\r\n-----\r\n\r\n- The calling signature for encoder functions follows that of the\r\n built-in\r\n `JSONEncoder `__\r\n with one exception:\r\n\r\n - If no modifications are needed and the object should be passed to\r\n the base encoder's handler, ``None`` should be returned. This\r\n differs from the normal method of calling\r\n ``super(MyEncoder, self).default(o)`` (that would most likely be\r\n an error since subclassing ``JSONEncoder`` isn't necessary).\r\n\r\n- The signature for decoder functions follows the ``object_hook``\r\n signature in `the built-in\r\n implementation `__\r\n\r\n.. |Build Status| image:: https://travis-ci.org/nocarryr/json-object-factory.svg?branch=master\r\n :target: https://travis-ci.org/nocarryr/json-object-factory\r\n.. |Coverage Status| image:: https://coveralls.io/repos/github/nocarryr/json-object-factory/badge.svg?branch=master\r\n :target: https://coveralls.io/github/nocarryr/json-object-factory?branch=master", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nocarryr/json-object-factory", "keywords": "json", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "json-object-factory", "package_url": "https://pypi.org/project/json-object-factory/", "platform": "any", "project_url": "https://pypi.org/project/json-object-factory/", "project_urls": { "Homepage": "https://github.com/nocarryr/json-object-factory" }, "release_url": "https://pypi.org/project/json-object-factory/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Simplify JSON Encoders and Object Hooks", "version": "0.0.2" }, "last_serial": 2145799, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "c6bd15c4e1b37518c0837796a47df5d9", "sha256": "ac23654ea7b25dde97a0ff4429a80cf3e4fabe9a493ff6bafaea9157591939f3" }, "downloads": -1, "filename": "json_object_factory-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c6bd15c4e1b37518c0837796a47df5d9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5473, "upload_time": "2016-06-01T15:13:39", "url": "https://files.pythonhosted.org/packages/ca/2d/6ccb4606482450758d682a1d2679649e1ef0cd8f210d382c48bbb8a887c5/json_object_factory-0.0.1-py2.py3-none-any.whl" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "58617fec45ae075f0cfbee37f323c340", "sha256": "3f6189fadce539dfd63ff975021fb9a00ba4a3f64f55a328c0119bbf45b28b5e" }, "downloads": -1, "filename": "json_object_factory-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "58617fec45ae075f0cfbee37f323c340", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5471, "upload_time": "2016-06-01T15:36:57", "url": "https://files.pythonhosted.org/packages/d2/a6/3aa1d4604fb871198c3e8b214d7f89d839eed6de0313622aec483e6b2d6f/json_object_factory-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "daf8067cb0c01489305f193fab88631d", "sha256": "73eecb07706d511ba2616851a19f229cc957cc1a426e285bce4686e557bd6af8" }, "downloads": -1, "filename": "json-object-factory-0.0.2.tar.gz", "has_sig": false, "md5_digest": "daf8067cb0c01489305f193fab88631d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2873, "upload_time": "2016-06-01T15:37:07", "url": "https://files.pythonhosted.org/packages/96/a8/38e15e5bc446c4afabe422c3e9c7ecad7402f446a2ea6d1b7f4dd83b0425/json-object-factory-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "58617fec45ae075f0cfbee37f323c340", "sha256": "3f6189fadce539dfd63ff975021fb9a00ba4a3f64f55a328c0119bbf45b28b5e" }, "downloads": -1, "filename": "json_object_factory-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "58617fec45ae075f0cfbee37f323c340", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 5471, "upload_time": "2016-06-01T15:36:57", "url": "https://files.pythonhosted.org/packages/d2/a6/3aa1d4604fb871198c3e8b214d7f89d839eed6de0313622aec483e6b2d6f/json_object_factory-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "daf8067cb0c01489305f193fab88631d", "sha256": "73eecb07706d511ba2616851a19f229cc957cc1a426e285bce4686e557bd6af8" }, "downloads": -1, "filename": "json-object-factory-0.0.2.tar.gz", "has_sig": false, "md5_digest": "daf8067cb0c01489305f193fab88631d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2873, "upload_time": "2016-06-01T15:37:07", "url": "https://files.pythonhosted.org/packages/96/a8/38e15e5bc446c4afabe422c3e9c7ecad7402f446a2ea6d1b7f4dd83b0425/json-object-factory-0.0.2.tar.gz" } ] }