deepdiff
                                
                                
                                
                                    deepdiff copied to clipboard
                            
                            
                            
                        from_json_pickle doesn't return a DeepDiff object
Describe the bug
The documentation for from_json_pickle implies that it will return a DeepDiff object with similar values to the ones created by to_json_pickle. This is not what it does. It returns a dictionary form of the DeepDiff. I'm unable to find a way to construct an actual DeepDiff object from this dictionary.
To Reproduce
>>> t1 = {1: 1, 2: 2, 3: 3}
>>> t2 = {1: 1, 2: "2", 3: 3}
>>> ddiff = DeepDiff(t1, t2)
>>> jsoned = ddiff.to_json_pickle()
>>> jsoned
'{"type_changes": {"root[2]": {"new_type": {"py/type": "builtins.str"}, "new_value": "2", "old_type": {"py/type": "builtins.int"}, "old_value": 2}}}'
>>> ddiff_new = DeepDiff.from_json_pickle(jsoned)
>>> ddiff == ddiff_new
True
>>> type(ddiff) == type(ddiff_new)
False
Expected behavior The expectation is that the final lines of the doctest look like this:
>>> type(ddiff) == type(ddiff_new)
True
OS, DeepDiff version and Python version (please complete the following information):
- OS: CentOS
 - Version 3.9
 
@gnu-lorien Have you tried to use the json_pickle package to unpickle it? I will update the docs.
The jsoned string doesn't have any class information in it, so I don't really know how to tell the jsonpickle to treat that dictionary as a DeepDiff, or to construct a DeepDiff from just one dictionary.
Digging through the code it looks like I can do this with:
tmp = DeepDiff({}, {})
tmp.update(ddiff_new)
Based on the documentation something like this is probably what from_json_pickle should do.
Turns out the method I expressed here doesn't actually work. Because t1 and t2 aren't set properly you can't actually use the class properly.
Hey @gnu-lorien Sorry I didn't get back to you. So is this still a problem?
Sort of. I wish there was a way to serialize the tree results so I could reload the DeepDiff object at a later time. Instead I've oriented the workflow out of the dictionary returned here, using Deltas, and then loading the previous base data to recreate the DeepDiff object.
I see. So you want to serialize everything including your original objects in the diff object. Can I ask you what the use case is?