How to make a Python class serializable?
A simple class:
class FileItem: def __init__(self, fname): self.fname = fname What should I doAttempt to be ableserialize to get output ofJSON:
>>> import json >>> my_filex = FileItem('/foo/bar') >>> json.dumps(my_filex) TypeError: Object of type 'FileItem' is not JSON serializable Without the error