saving and loading objects from file using jsonpickle

后端 未结 3 2041
迷失自我
迷失自我 2021-02-02 12:14

I have the following simple methods for writing a python object to a file using jsonpickle:

def json_serialize(obj, filename, use_jsonpickle=True):
    f = open(         


        
3条回答
  •  不思量自难忘°
    2021-02-02 12:33

    The correct answer was that I was not inheriting from object. Without inheriting from object, jsonpickle cannot correctly decode classes that take one or more arguments in the constructor, it seems. I am by no means an expert but making it Foo(object): rather than Foo: in the class declaration fixed it.

提交回复
热议问题