MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / unserialize_object

Function unserialize_object

src/6/reading_and_writing_json_data/example.py:45–54  ·  view source on GitHub ↗
(d)

Source from the content-addressed store, hash-verified

43}
44
45def unserialize_object(d):
46 clsname = d.pop('__classname__', None)
47 if clsname:
48 cls = classes[clsname]
49 obj = cls.__new__(cls)
50 for key, value in d.items():
51 setattr(obj, key, value)
52 return obj
53 else:
54 return d
55
56a = json.loads(s, object_hook=unserialize_object)
57print(a)

Callers

nothing calls this directly

Calls 2

popMethod · 0.45
__new__Method · 0.45

Tested by

no test coverage detected