def scrub(x):
    ret = copy.deepcopy(x)
if isinstance(x, dict):
    for k, v in list(ret.items()):
        ret[k] = scrub(v)
if x == None:
    ret = ''
return ret
Python: How json dumps None to empty string