I have strings like these - Trang chủ
and Đồ Dùng Nhà Bếp
which have special charaters. When i print them, they are shown as it is. But when I convert it into Json, it changes to Trang ch\xe1\xbb\xa7
. How can I print them as they are in JSON format also? Thanks in advance.
I tried the suggested answer of -
string.encode('utf-8', "ignore")
string.decode("ascii", "ignore")
and got this error:
UnicodeDecodeError('ascii', 'Trang ch\xe1\xbb\xa7', 8, 9, 'ordinal not in range(128)')
Is there a way around?
The link provided as duplicate is not the question I was asking.
The answer provided does solve my question : json.dumps(your_string, ensure_ascii=False)