to_dict
Project description
jsoncodable
Description
Easily create object from any dict/jsonstr/jsonfile and dict/jsonstr/jsonfile from any object From v0.1.0 it is based on jsonpickle
Install
pip install jsoncodable
# or
pip3 install jsoncodable
Usage
from jsoncodable import JSONCodable
class BirthDay(JSONCodable):
def __init__(
self,
month: int,
day: int
):
self.month = month
self.day = day
class Person(JSONCodable):
def __init__(
self,
name: str,
birth_month: int,
birth_day: int
):
self.name = name
self.birth_day = BirthDay(birth_month, birth_day)
person = Person(
name='John',
birth_month=7,
birth_day=7
)
person.jsonprint()
# prints
#
# {
# "name": "John",
# "birth_day": {
# "month": 7,
# "day": 7
# }
# }
Person.load(person.json).jsonprint()
# prints
#
# {
# "name": "John",
# "birth_day": {
# "month": 7,
# "day": 7
# }
# }
Dependencies
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
jsoncodable-0.1.1.tar.gz
(3.8 kB
view hashes)
Built Distribution
Close
Hashes for jsoncodable-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05e1c87e47849bcdc02417209a81bd424916eae1b4d12f4d40ae934b6298e075 |
|
MD5 | 361c94d9475f4583222143ab1f92bf72 |
|
BLAKE2b-256 | 70fcc2f640e5931c24c3e68c20e0eee7a3b1fa682d1745e57b7776f030d308dd |