data = {
"name": "foo",
"age": 27
}
with open("test.json", 'w', encoding='utf8') as outfile:
json.dump(data, outfile, indent=2)
>>> json_string = json.dumps("ברי צקלה", ensure_ascii=False).encode('utf8')
>>> json_string
b'"xd7x91xd7xa8xd7x99 xd7xa6xd7xa7xd7x9cxd7x94"'
>>> print(json_string.decode())
"ברי צקלה"