jsonable-0.3.1
توضیحات
An abstract class that supports jsonserialization/deserialization.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | jsonable-0.3.1 |
| نام | jsonable |
| نسخه کتابخانه | 0.3.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Aaron Halfaker |
| ایمیل نویسنده | ahalfaker@wikimedia.org |
| آدرس صفحه اصلی | https://github.com/halfak/JSONable-data-types |
| آدرس اینترنتی | https://pypi.org/project/jsonable/ |
| مجوز | MIT |
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
نحوه نصب
نصب پکیج whl jsonable-0.3.1:
pip install jsonable-0.3.1.whl
نصب پکیج tar.gz jsonable-0.3.1:
pip install jsonable-0.3.1.tar.gz