Skip to content

datenhahn/python-sassyjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sassyjson

sassyjson is an automatic json objectmapper for python.

Install

pip install 

Usage

@dataclass
class MyNestedClass:
    message: str

@dataclass
class MyCustomClass:
    timestamp: datetime
    nested_message: MyNestedClass

 
my_instance = MyCustomClass(timestamp=datetime(2022,6,17),
                            nested_message=MyNestedClass("Hello World!"))

# Will generate the following string from the instance:
# '{"nested_message": {"message": "Hello World!"}, "timestamp": "2022-06-17T00:00:00.000000"}'
json_string = sassyjson.to_json(my_instance)

# Will generate a new MyCustomClass instance from the json string
new_instance = sassyjson.from_json(json_string, MyCustomClass)

About

sassyjson is an automatic json objectmapper for python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages