I have a large nested dictionary with strings, floats and integers as data. I want to dump it into a JSON string, but a direct dump gives me an error:
json_dictionary = json.dumps(mapped_dictionary)
TypeError: Object of type int64 is not JSON serializable
So I tried to use this:
json_dictionary = json.dumps(str(mapped_dictionary))
This seemed to work at first but then I found out that the str
function on the nested dictionary truncates the values after a certain point and then shows the rest of content. It's not dumping the entire nested dictionary, which is rather large.
I am wondering if there is a limit to the str
function, and if so, what is a good workaround to have a nested dictionary with mixed type data to be dumped into a JSON object?