JSON-able data types
====================
This library provides and abstract base class ``JSONable`` which enables easy definition of trivially JSON-able python objects.
* **Installation:** ``pip install jsonable``
:Example:
>>> import jsonable
>>>
>>>
>>> class Fruit(jsonable.Type):
... __slots__ = ('type', 'weight')
...
... def initialize(self, type, weight):
... self.type = str(type)
... self.weight = float(weight)
...
>>> class Pie(jsonable.Type):
... __slots__ = ('fruit',)
...
... def initialize(self, fruit):
... self.fruit = [Fruit(f) for f in fruit]
...
...
>>> pie = Pie([Fruit('apple', 10.3), Fruit('cherry', 2)])
>>>
>>> doc = pie.to_json()
>>> doc
{'fruit': [{'weight': 10.3, 'type': 'apple'}, {'weight': 2.0, 'type': 'cherry'}]}
>>>
>>> pie == Pie(doc)
True
Raw data
{
"_id": null,
"home_page": "https://github.com/halfak/JSONable-data-types",
"name": "jsonable",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Aaron Halfaker",
"author_email": "ahalfaker@wikimedia.org",
"download_url": "https://files.pythonhosted.org/packages/47/f1/e02151747f823dc9f13900f19d9fd61cc6aa01a5e90b3f8c2b4131bd619c/jsonable-0.3.1.tar.gz",
"platform": "UNKNOWN",
"description": "JSON-able data types\n====================\n\nThis library provides and abstract base class ``JSONable`` which enables easy definition of trivially JSON-able python objects.\n\n* **Installation:** ``pip install jsonable``\n\n:Example:\n\n >>> import jsonable\n >>>\n >>>\n >>> class Fruit(jsonable.Type):\n ... __slots__ = ('type', 'weight')\n ...\n ... def initialize(self, type, weight):\n ... self.type = str(type)\n ... self.weight = float(weight)\n ...\n >>> class Pie(jsonable.Type):\n ... __slots__ = ('fruit',)\n ...\n ... def initialize(self, fruit):\n ... self.fruit = [Fruit(f) for f in fruit]\n ...\n ...\n >>> pie = Pie([Fruit('apple', 10.3), Fruit('cherry', 2)])\n >>>\n >>> doc = pie.to_json()\n >>> doc\n {'fruit': [{'weight': 10.3, 'type': 'apple'}, {'weight': 2.0, 'type': 'cherry'}]}\n >>>\n >>> pie == Pie(doc)\n True",
"bugtrack_url": null,
"license": "MIT",
"summary": "An abstract class that supports jsonserialization/deserialization.",
"version": "0.3.1",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "cbb3ff7b9db8ad4520d0821b2664388d",
"sha256": "f7754dd27b4734e42e7f8a61c2336bc98082f715e31e29a061a95843b102dc3a"
},
"downloads": -1,
"filename": "jsonable-0.3.1-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "cbb3ff7b9db8ad4520d0821b2664388d",
"packagetype": "bdist_wheel",
"python_version": "3.4",
"requires_python": null,
"size": 11050,
"upload_time": "2015-10-01T14:45:04",
"upload_time_iso_8601": "2015-10-01T14:45:04.942580Z",
"url": "https://files.pythonhosted.org/packages/0e/55/c6bcb4ec7f93bf8f98b57d7e185cf5ee02b52473ed84d5611277f710cdcc/jsonable-0.3.1-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "65801e0a7172c8ba959ac95c0bedbb8f",
"sha256": "137b676e8e5819fa58518678c3d1f5463cab7e8466f69b3641cbc438042eaee4"
},
"downloads": -1,
"filename": "jsonable-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "65801e0a7172c8ba959ac95c0bedbb8f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5528,
"upload_time": "2015-10-01T14:44:55",
"upload_time_iso_8601": "2015-10-01T14:44:55.428005Z",
"url": "https://files.pythonhosted.org/packages/47/f1/e02151747f823dc9f13900f19d9fd61cc6aa01a5e90b3f8c2b4131bd619c/jsonable-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2015-10-01 14:44:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "halfak",
"github_project": "JSONable-data-types",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "jsonable"
}