0
d = {'name' : 'Chris Wilder',
'job': 'Soccer Manager \n'}

with open('filepath','w') as f:
    json.dump(d, f)

Expected:
{'name' : 'Chris Wilder','job': 'Soccer Manager at Spur's \n'}
Actual:
{'name' : 'Chris Wilder','job': 'Soccer Manager at Spur\u2019s \n'}

There are other unicode characters being encoded such as some chinese symbols like \uf0f0. Is there a way to avoid creating these unicode characters or is it inevitable?

How should I solve this issue?

coderboi
  • 161
  • 3
  • 22
  • Your example doesn't match your output, namely, `d['job']`. – iBug May 15 '21 at 12:04
  • You need ```ensure_ascii=False```. How to use it: https://stackoverflow.com/questions/18337407/saving-utf-8-texts-with-json-dumps-as-utf8-not-as-u-escape-sequence – Hemera May 15 '21 at 13:00

0 Answers0