Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ibrahimgunduz34/serializable
Serializable is simple transfer object library to create simple serializable objects.
https://github.com/ibrahimgunduz34/serializable
Last synced: about 1 month ago
JSON representation
Serializable is simple transfer object library to create simple serializable objects.
- Host: GitHub
- URL: https://github.com/ibrahimgunduz34/serializable
- Owner: ibrahimgunduz34
- Created: 2014-01-28T09:24:56.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-06T06:09:14.000Z (almost 11 years ago)
- Last Synced: 2023-03-24T03:13:36.448Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 164 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Serializable
============Serializable is simple transfer object library to create simple serializable objects.
## Usage:
Define your transfer objects first.
```python
from serializable.base import AbstractObjectclass PaymentObject(AbstractObject):
attributes = ['transaction_id', 'amount']class OrderObject(AbstractObject):
attributes = ['order_id', 'payment']
schema = {'payment': PaymentObject}
```Serialization:
```python
order = OrderObject(order_id='OR0000001', payment=PaymentObject(transaction_id='TR000002', amount=100))serialized = order.serialize()
"""
serialized contains now:{'data': {'order_id': 'OR0000001',
'payment': {'data': {'amount': 100, 'transaction_id': 'TR000002'},
'object_type': 'app.stores.PaymentObject'}},
'object_type': 'app.stores.OrderObject'}
"""```
Deserialization:
```python
order = OrderObject()
order.deserialize(serialized)print order.get_order_id()
"""
result:
OR0000001
"""print order.get_payment().get_transaction_id()
"""
result:
TR000002
"""
```