Name | jstruct JSON |
Version |
2021.11
JSON |
| download |
home_page | https://github.com/purplship/jstruct |
Summary | Readable serializable and deserializable Python nested models |
upload_time | 2021-11-21 05:42:09 |
maintainer | |
docs_url | None |
author | DanielK |
requires_python | |
license | MIT |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# jstruct
An eloquent and opinionated python library for nested object models definition offering simple serialization and deserialization into python dictionaries.
[](https://github.com/purplship/jstruct)
[](https://www.codacy.com/gh/purplship/jstruct/dashboard?utm_source=github.com&utm_medium=referral&utm_content=purplship/jstruct&utm_campaign=Badge_Grade)
[](https://github.com/python/black)
[](https://opensource.org/licenses/MIT)
## Why
The deserialization of JSON or yaml into python data types is a common practice useful in many ways.
- Configuration file reading and writing
- REST API message response generation and request processing
- Object-Document Mapping for a document store
- Data import parsing or export generation
## How
`JStruct` leverage [attrs](https://www.attrs.org/en/stable/) the great `Classes without boilerplate` library to define structs without boilerplate.
## What
The result is a simple and intuitive syntax familiar to a pythonista that brings `Validation`, `Deserialization` and `Serialization`.
## Requirements
- Python 3.6 and +
## Installation
Install using pip
```shell
pip install jstruct
```
## Usage
```python
import attr
from typing import List
from jstruct import struct, JList
@struct
class Person:
first_name: str
last_name: str
@struct
class RoleModels:
scientists: List[Person] = JList[Person]
payload = {
"scientists": [{"first_name": "John", "last_name": "Doe"}]
}
role_models = RoleModels(**payload)
print(role_models)
# RoleModels(scientists=[Person(first_name='John', last_name='Doe')])
print(attr.asdict(role_models))
# {'scientists': [{'first_name': 'John', 'last_name': 'Doe'}]}
```
## Authors
- **Daniel K.** - [@DanHK91](https://twitter.com/DanHK91) | [https://danielk.xyz](https://danielk.xyz/)
## Contribute
Contributors are welcomed.
## License
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/DanH91/jstruct/blob/document-jstruct/LICENSE) file for details
Raw data
{
"_id": null,
"home_page": "https://github.com/purplship/jstruct",
"name": "jstruct",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "DanielK",
"author_email": "danielk.developer@gmail.com",
"download_url": "",
"platform": "",
"description": "# jstruct\n\nAn eloquent and opinionated python library for nested object models definition offering simple serialization and deserialization into python dictionaries.\n\n[](https://github.com/purplship/jstruct)\n[](https://www.codacy.com/gh/purplship/jstruct/dashboard?utm_source=github.com&utm_medium=referral&utm_content=purplship/jstruct&utm_campaign=Badge_Grade)\n[](https://github.com/python/black)\n[](https://opensource.org/licenses/MIT)\n\n## Why\n\nThe deserialization of JSON or yaml into python data types is a common practice useful in many ways.\n - Configuration file reading and writing\n - REST API message response generation and request processing\n - Object-Document Mapping for a document store\n - Data import parsing or export generation \n\n## How\n\n`JStruct` leverage [attrs](https://www.attrs.org/en/stable/) the great `Classes without boilerplate` library to define structs without boilerplate.\n\n## What\n\nThe result is a simple and intuitive syntax familiar to a pythonista that brings `Validation`, `Deserialization` and `Serialization`.\n\n## Requirements\n\n - Python 3.6 and +\n\n## Installation\n\nInstall using pip\n\n```shell\npip install jstruct\n```\n\n## Usage\n\n```python\nimport attr\nfrom typing import List\nfrom jstruct import struct, JList\n\n@struct\nclass Person:\n first_name: str\n last_name: str\n\n@struct\nclass RoleModels:\n scientists: List[Person] = JList[Person]\n\n\npayload = {\n \"scientists\": [{\"first_name\": \"John\", \"last_name\": \"Doe\"}] \n}\n\nrole_models = RoleModels(**payload)\n\nprint(role_models)\n\n# RoleModels(scientists=[Person(first_name='John', last_name='Doe')])\n\nprint(attr.asdict(role_models))\n\n# {'scientists': [{'first_name': 'John', 'last_name': 'Doe'}]}\n\n```\n\n## Authors\n\n- **Daniel K.** - [@DanHK91](https://twitter.com/DanHK91) | [https://danielk.xyz](https://danielk.xyz/) \n\n## Contribute\n\nContributors are welcomed.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](https://github.com/DanH91/jstruct/blob/document-jstruct/LICENSE) file for details\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Readable serializable and deserializable Python nested models",
"version": "2021.11",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "1ce67a14ce1e2897c9da46915876a1a9",
"sha256": "0b1a7f3f88e34051b372953e0e6f88c465ddd84cdd7e15e5de10a8eeb6863485"
},
"downloads": -1,
"filename": "jstruct-2021.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1ce67a14ce1e2897c9da46915876a1a9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5484,
"upload_time": "2021-11-21T05:42:09",
"upload_time_iso_8601": "2021-11-21T05:42:09.296992Z",
"url": "https://files.pythonhosted.org/packages/b5/23/f99cc3785451817849451e0f9fb0f1cc3045ed8f5d2e49292fdced474579/jstruct-2021.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2021-11-21 05:42:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "purplship",
"github_project": "jstruct",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "jstruct"
}