I have a dictionary containing arabic words like
data = [{'name': 'آدَم'}, {'name': 'آزَر'}]
print(json.dumps(data), file=open('data.json', 'a', encoding="utf-8"))
Output:
[{"name": "\u0622\u0632\u064e\u0631"}...]
I don't want to encode the arabic text while creating the data.json file. If I do not use json.dumps then it works fine but then it shows single quotes ' instead of double qoutes "
Pass the parameter ensure_ascii = False
:
json.dumps(data, ensure_ascii = False)
Documentation here.
If ensure_ascii is true (the default), the output is guaranteed to have all incoming non-ASCII characters escaped. If ensure_ascii is false, these characters will be output as-is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With