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)
1
  • Will move all my content out of SO anyway. Duplicate? Laughable. Oct 13, 2014 at 22:28

1 Answer 1

0

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

jsonified = json.dumps(json_data,ensure_ascii=False ).encode('utf8')
print jsonified
3

Not the answer you're looking for? Browse other questions tagged or ask your own question.