0

I need to format this dict into json format: replacing the general aprostrophe is no problem. I have trouble with replacing the aprostrophe in the value of "cityTo"

data = {
'id': 'xxx',
'flyFrom': 'HAM',
'flyTo': 'GND', 
'cityFrom': 'Hamburg',
'cityCodeFrom': 'HAM',
'cityTo': "St George's",
'cityCodeTo': 'GND',
'countryFrom': {'code': 'DE',
                'name': 'Germany'}
}

Until I noticed this aprostrophe I formatted like this:

str(data).replace("'", '"').replace("None", '"None"').replace("False", '"False"').replace("True", '"True"')

but this incudes the mentioned aprostrophe .

ImEcho
  • 13
  • 4

0 Answers0