I am inexperienced with API’s so maybe this has a really simple solution.
I was trying to save the data that I get through the summary.search() function in json format. I am trying to do this because I wish to pass on the summary data into a Matlab script I am working on, and thought using json would be the easiest way to do so. I am open to trying out other formats if they’re more helpful.
I use the following code
#thenext line basically exists so that i can enter a material_id in the console when i run this python script
mat_id=sys.argv.pop() with MPRester(MP_API_KEY) as mpr: Preformatted textyour_material= mpr.summary.search(material_ids=[mat_id],fields=list_of_properties,all_fields=False) your_material.json()
and get the following error message:
TypeError: Object of type ‘Composition’ is not JSON serializable
I have tried other ways of achieving this , for example:
which causes the error
TypeError: Object of type Element is not JSON serializable
so if anyone has any tips or suggestion for me I would greatly appreciate it!