Removig backlashes from get request json in Flask

Viewed 31

How can I remove the backlashes in my json response fetched from my API?

client = pymongo.MongoClient('cred')
result = client['db']['Todo'].find(
  filter=filter,
  projection=project
)
json_response = json.dumps(list(result), default=json_util.default)
dog = json.loads(json_response)

df = pd.DataFrame(dog)

df=df.pivot_table(index=['Breed'], aggfunc = 'count')
df = df.reset_index().to_json(orient='records')
parsed=json.dumps(df,ensure_ascii= True, default=json_util.default)
return json.loads(parsed)

currently I am getting this response:

{"_id":{"Bolognese":1,"Papillon":1}}

my original dataframe in json:

{"_id":{"0":"cOBeGkhatb","1":"7S8YemMoMq"},"Breed":{"0":"Papillon","1":"Bolognese"}}
1 Answers

Okay, when I fetch my response in my app the backlashes does not really matter, but I was concerned because in my browser I saw them and I thought that would lead to a wrong data fetching

Related