I've the json data in below format and I'm trying to store it in JSON file but it's storing in encoded form in data.json file
data= {"a": "{0}さんではないですか?"}
with open('data.json', 'w') as fp:
fp.write(json.dumps(data).encode("utf8"))
data.json
{"a": "{0}\u3055\u3093\u3067\u306f\u306a\u3044\u3067\u3059\u304b\uff1f"}
I want data.json to be in this format
{"a": "{0}さんではないですか?"}
I tried encoding it and then putting it in json file, no success.. can anybody tell what I'm doing wrong here and what is the right way?
Try using json.dumps(s, ensure_ascii=False)
.
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