How can I convert dict to 'MPDataDoc' object back?

I saved the data to json by converting the elements from ‘MPDataDoc’ object to dict. I want to change the type back when I load the json file to script. Would it have a function to do?

Does the following thread help? Saving MPRester/MPDataDoc objects

Yes it helped me to save the data to json but when I load the file to script, the type of element is dict and I want to change it to ‘MPDataDoc’ type back. I tried from_dict from Structure and Composition class. it did not work.

monty’s loadfn currently doesn’t automatically take care of deserializing to MPDataDoc (or better the original type corresponding to the endpoint, i.e. SummaryDoc). You’d have to hand the dict to the SummaryDoc constructor explicitly. Something like:

from emmet.core.summary import SummaryDoc

data = loadfn("...")

for d in data:
    doc = SummaryDoc(**d)

Tagging @munrojm to help with the details if needed.