Serialization and Deserialization
- An object is something that lives in application memory & we can invoke method or attributs in our application, Howerver, when we want to transfer or store an object we will have to convert it into storable or transferrable format, and that format is stream of bytes, which can then be stored ina text file, in a database or be transmitted over internet.
- The process of converting an object to stream of bytes is called as serialization & the stream of bytes will persist the object’s state.
- The recreation of object from of stream of bytes is called as deserialization
- In standard python we have a pickle module implements binary protocols for serializing and deserializing a Python object structure.
- Marshmallow itself is an excellent package for serialization and deserialization in python, aw well as providing validation features.
- It allows developers to define schemas, which can be used to represent a filed in various ways and automatically will perform validation during deserialization. Refer Here for the official docs of marsh mallow
- Refer Here for the documentation index
- Refer Here for the FLASK SQL Alchemy and marshmallow example
- Refer Here for the file created to use model and schema