Name | j-classify JSON |
Version |
1.0.0
JSON |
| download |
home_page | |
Summary | Improved JSON deserialization for Python |
upload_time | 2023-10-10 20:23:30 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7.0 |
license | MIT License Copyright (c) 2023 Gabriel Reed Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
json
deserialization
serialization
object
mapping
mapping
dict
dictionary
dataclass
dataclasses
data
class
classes
jsonobject
json-object
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# j_classify
Improved JSON deserializer for Python that allows for remapping to custom object types and nested objects. This allows for saving/loading complex Python objects, like using `pickle` while still preserving them in a human-readable format.
## Installation
``` bash
pip install j_classify
```
## Usage
``` python
import json
import j_classify
class test_class_1(j_classify.j_object):
def __init__(self) -> None:
super().__init__()
self.name = "test_class_1"
self.number = 1
self.boolean = True
self.children: list = []
class test_class_2(j_classify.j_object):
def __init__(self) -> None:
super().__init__()
self.name = "test_class_2"
self.number = 2
self.boolean = False
self.children: list = []
class test_class_3(j_classify.j_object):
def __init__(self) -> None:
super().__init__()
self.name = "test_class_3"
self.number = 3
self.boolean = True
if __name__ == "__main__":
obj_1 = test_class_1()
obj_1.name = "obj_1"
obj_1.number = 2
obj_1.boolean = False
obj_2 = test_class_2()
obj_2.name = "obj_2"
obj_2.number = 3
obj_2.boolean = True
obj_1.children.append(obj_2)
obj_3 = test_class_3()
obj_3.name = "obj_3"
obj_3.number = 4
obj_3.boolean = False
obj_2.children.append(obj_3)
# Dump the object to JSON - use the j_object_encoder class for the cls argument
obj_data = json.dumps(obj_1, cls=j_classify.j_object_encoder, indent=4)
# Load the object from JSON - use the load_j_object function for the object_hook
loaded_obj_1 = json.loads(obj_data, object_hook=j_classify.load_j_object)
```
Raw data
{
"_id": null,
"home_page": "",
"name": "j-classify",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.0",
"maintainer_email": "",
"keywords": "json,deserialization,serialization,object,mapping,mapping,dict,dictionary,dataclass,dataclasses,data,class,classes,jsonobject,json-object",
"author": "",
"author_email": "Gabe Reed <gabrieljreed@gmail.com>",
"download_url": "",
"platform": null,
"description": "# j_classify\r\n\r\nImproved JSON deserializer for Python that allows for remapping to custom object types and nested objects. This allows for saving/loading complex Python objects, like using `pickle` while still preserving them in a human-readable format.\r\n\r\n## Installation\r\n\r\n``` bash\r\npip install j_classify\r\n```\r\n\r\n## Usage\r\n\r\n``` python\r\nimport json\r\n\r\nimport j_classify\r\n\r\n\r\nclass test_class_1(j_classify.j_object):\r\n def __init__(self) -> None:\r\n super().__init__()\r\n self.name = \"test_class_1\"\r\n self.number = 1\r\n self.boolean = True\r\n self.children: list = []\r\n\r\n\r\nclass test_class_2(j_classify.j_object):\r\n def __init__(self) -> None:\r\n super().__init__()\r\n self.name = \"test_class_2\"\r\n self.number = 2\r\n self.boolean = False\r\n self.children: list = []\r\n\r\n\r\nclass test_class_3(j_classify.j_object):\r\n def __init__(self) -> None:\r\n super().__init__()\r\n self.name = \"test_class_3\"\r\n self.number = 3\r\n self.boolean = True\r\n\r\n\r\nif __name__ == \"__main__\":\r\n obj_1 = test_class_1()\r\n obj_1.name = \"obj_1\"\r\n obj_1.number = 2\r\n obj_1.boolean = False\r\n\r\n obj_2 = test_class_2()\r\n obj_2.name = \"obj_2\"\r\n obj_2.number = 3\r\n obj_2.boolean = True\r\n obj_1.children.append(obj_2)\r\n\r\n obj_3 = test_class_3()\r\n obj_3.name = \"obj_3\"\r\n obj_3.number = 4\r\n obj_3.boolean = False\r\n obj_2.children.append(obj_3)\r\n\r\n # Dump the object to JSON - use the j_object_encoder class for the cls argument\r\n obj_data = json.dumps(obj_1, cls=j_classify.j_object_encoder, indent=4)\r\n\r\n # Load the object from JSON - use the load_j_object function for the object_hook\r\n loaded_obj_1 = json.loads(obj_data, object_hook=j_classify.load_j_object)\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2023 Gabriel Reed Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Improved JSON deserialization for Python",
"version": "1.0.0",
"project_urls": {
"Bug Tracker": "https://github.com/gabrieljreed/jObject/issues",
"Homepage": "https://github.com/gabrieljreed/jObject"
},
"split_keywords": [
"json",
"deserialization",
"serialization",
"object",
"mapping",
"mapping",
"dict",
"dictionary",
"dataclass",
"dataclasses",
"data",
"class",
"classes",
"jsonobject",
"json-object"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "810145e8695155a8c2b11f5b41c7a4722f0468c03c5787665b1d20699d0e7a5f",
"md5": "5f9a726919d0652d9a49158f3441c131",
"sha256": "ae9660ff4474727c73e2a8b3f4f38d00914bcfc90aa914d92505cab5f700a92e"
},
"downloads": -1,
"filename": "j_classify-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5f9a726919d0652d9a49158f3441c131",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.0",
"size": 4476,
"upload_time": "2023-10-10T20:23:30",
"upload_time_iso_8601": "2023-10-10T20:23:30.081645Z",
"url": "https://files.pythonhosted.org/packages/81/01/45e8695155a8c2b11f5b41c7a4722f0468c03c5787665b1d20699d0e7a5f/j_classify-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-10 20:23:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gabrieljreed",
"github_project": "jObject",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "j-classify"
}