P
P
porch2021-08-03 18:28:07
Python
porch, 2021-08-03 18:28:07

How to save JSON with Cyrillic so that it is readable?

Greetings.
There is a dictionary and it needs to be converted to JSON so that it is readable. I do it like this:

nmbrs = 
{
    "one": "Один",
    "two": "Два",
    "three": "Три",
    "four": "Четыре"
}

print(json.dumps(nmbrs))

# получается вот это
# {"one": "\u041e\u0434\u0438\u043d", "two": "\u0414\u0432\u0430", "three": "\u0422\u0440\u0438", "four": "\u0427\u0435\u0442\u044b\u0440\u0435"}

How to make JSON readable in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aRegius, 2021-08-03
@weranda

Пропишите параметр ensure_ascii равным False:
.dumps(nmbrs, ensure_ascii=False)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question