Use json.dumps() instead. json.dump() needs a file object and dump JSON to it.
json.dumps()
json.dump()