Python JSON loads/dumps breaks Unicode?

Viewed 15976

Dumping a string that contains unicode characters as json produces weird unicode escape sequences:

text = "⌂⚘いの法嫁"
print(text) # output: ⌂⚘いの法嫁

import json
json_text = json.dumps(text)
print(json_text) # output: "\u2302\u2698\u3044\u306e\u6cd5\u5ac1"

I'd like to get this output instead:

"⌂⚘いの法嫁"

How can I dump unicode characters as characters instead of escape sequences?

1 Answers
Related