Skip to content

Automatic custom class JSON serialization/deserialization

License

Notifications You must be signed in to change notification settings

AlbertFX91/jsonty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jsonty

Jsonty is an automatic JSON serialization/deseralization Python library for your custom classes.

Build Status GitHub issues Coverage License

How it works

Jsonty serialize and deserialize your custom objects by its annotations. All you have to do is define its attributes and make sure that are added in the constructor

import jsonty
class Toy(jsonty.Model):
    name: str
    uses: int

    def __init__(self, name: str, uses: int):
        self.name = name
        self.uses = uses
# Object creation
toy: Toy = Toy(name='white car', uses=10)
# Dumps operation
toy_json: str = toy.dumps() # { 'name': 'white car', 'uses': 10 }
# Loads operation
toy_recoverying: Toy = Toy.loads(toy_json) # The json representation is converted into a Toy object

Operations supported

There are a range of types that jsonty can handle such as:

  • Basic data types: str, int, bool, number
  • Iterables: List, Dict, Set, Tuple
  • Model Inheritance

Links

About

Automatic custom class JSON serialization/deserialization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published