Serialize any object to db