this logic manipulate json data as a string  it is really a bad idea json is a string representation of a structured data  so we should manipulate the data first and then dump it as json  this means params request post copy cleanup params return json dumps params if post data is nested  you need to use copy deepcopy 