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)
stevek-pro
  • 13,672
  • 14
  • 81
  • 134

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
  • 100,514
  • 17
  • 155
  • 179