For serializing Python objects to JSON (dicts) and back
Project description
_ (_) _ ___ ___ _ __ ___ | / __|/ _ \| '_ \/ __| | \__ | (_) | | | \__ \ | |___/\___/|_| |_|___/ _/ | JSON SERIALIZATION |__/ MADE EASY!
~ Any Python objects to/from JSON, easily! ~
|
Example of a model to be serialized:
Example of the serialization:
Output after serialization:
|
Installation
pip install jsons
Usage
import jsons
some_instance = jsons.load(some_dict, SomeClass) # Deserialization
some_dict = jsons.dump(some_instance) # Serialization
In some cases, you have instances that contain other instances that need (de)serialization, for instance with lists or dicts. You can use the typing classes for this as is demonstrated below.
from typing import List, Tuple
import jsons
# For more complex deserialization with generic types, use the typing module
list_of_tuples = jsons.load(some_dict, List[Tuple[AClass, AnotherClass]])
(For more examples, see the FAQ)
Documentation
Meta
Recent updates
0.8.4
Feature: Support for textual type hints.
Feature: Automatically announce classes when dumped.
Bugfix: Support for from __future__ import annotations
0.8.3
Bugfix: Loading verbose dumped objects could fail if lists where involved.
0.8.2
Bugfix: Dumping a namedtuple resulted in a list rather than a dict.
Feature: Loading into named tuples can be from lists and dicts.
0.8.1
Bugfix: Loading a verbose dump worked only shallow.
0.8.0
Feature: Dumping objects can be verbose.
Feature: Loading enums without use_enum_name can be with names or values.
Bugfix: Loading empty namedtuples caused a problem.
0.7.2
Bugfix: Package problem.
Contributors
Special thanks to the following contributors:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsons-0.8.4.tar.gz.
File metadata
- Download URL: jsons-0.8.4.tar.gz
- Upload date:
- Size: 24.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d47cbd3747c36c66960a3447bd972ecb8540bbe20bb786a7957453d1d6ab3c1c
|
|
| MD5 |
a8e5baee119362f4970c2522cd6d8622
|
|
| BLAKE2b-256 |
3662e269693bac3cb55827a13fe9c8c6acb0977e38015152591035bc70e70b98
|
File details
Details for the file jsons-0.8.4-py3-none-any.whl.
File metadata
- Download URL: jsons-0.8.4-py3-none-any.whl
- Upload date:
- Size: 33.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
978e783bd51477c1d6f5839defeb2dae3ef24f7b4d3e6616cbcc6cf28765f3b5
|
|
| MD5 |
83022215ff9f746c65356bceed5b9dd4
|
|
| BLAKE2b-256 |
76f30515a6322b91cc4f99857afcd9d115be0b2b4080b5feb39f55dd35f377b4
|