Fix JSON parsing in flask