I\'m using SQLAlchemy extension with Flask. While serializing my models (which are also used for database operations) using jsonpickle, I want some specific attributes
This one will help others to get their task done:
Make a class like this one in a package like your custom jsonpickle
package:
class SetGetState:
def __getstate__(self):
state = self.__dict__.copy()
try:
class_name = '_' + self.__class__.__name__ + '__'
new_items = {key:value for key, value in state.items() if class_name not in key}
return new_items
except KeyError:
pass
return state
And inherit this one in the class requires no private property serialization
class Availability(jsonpickle.SetGetState):
pass