0

This is my Python Code:

json_data = {
    "data":"ä"  
}

print (json_data)
# "data":"\xe4"

jsonified = json.dumps(json_data)
print (jsonified)
# same as above, "data":"\xe4"

How can I hinder Python or tell Json Dumps Method to not alter my special characters?

Update: After applying below suggestions I am getting:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 52: ordinal not in range(128)
Stephan Kristyn
  • 15,015
  • 14
  • 88
  • 147

1 Answers1

0

you need to use ensure_ascii=False then encode('utf8') :

jsonified = json.dumps(json_data,ensure_ascii=False ).encode('utf8')
print jsonified
Mazdak
  • 105,000
  • 18
  • 159
  • 188