Had a similar issues, it was caused by another custom module. I named another script
json.py
and it turns out it tried to load the custom json.py file as a module. dumps method is obviously not available there.
Renaming the json.py script to something else (json2.py) got rid of the issue.