Answer the question
In order to leave comments, you need to log in
How to work with Cyrillic in JSON?
I have a class:
import json
import atexit
class JSONController:
def __init__(self, filename):
self.handler = open(filename, 'r+', encoding='utf-8')
atexit.register(self.close)
def load(self):
text = self.handler.read()
return json.loads(text)
def save(self, data):
text = json.dumps(data, ensure_ascii=True, indent=4)
self.handler.seek(0)
self.handler.truncate()
self.handler.write(text)
def close(self):
self.handler.close()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question