I have a pickled object that I want to load. However, Pickle gives some strange (possibly memory-related) errors, that are briefly described here as well:
Python Pickling Dictionary EOFError
When loading, it simply gives an EOF error, while it does for smaller objects. Saving the object as a JSON was impossible (this How to make a class JSON serializable did not work for example), because of this error: AttributeError: 'numpy.ndarray' object has no attribute 'dict', which was very strange. When I check for the type of all values in the objects there are no arrays there...so if anyone knows how to solve this it is appreciated as well!
Anyway, I want to avoid this and to read the object via JSON instead of Pickle (or any other way for that matter). Is this at all possible? Are there any workarounds for this problem? Is is possible to convert it somehow after I already stored the Pickled objects, without reading it with Pickle!
Thanks in advance, greatly appreciated!
No. The
json
module cannot read pickled data, as Pickle is not JSON. Converting Pickle to JSON would be equivalent to unpickling and then serializing as JSON, both of which you've said aren't working.