Answer the question
In order to leave comments, you need to log in
After converting the object to json format (json.dumps), escaped ascii characters are displayed instead of text. How to fix?
Strings come from outside in different encodings.
I need to form a json object from them, but after conversion, escaped characters are displayed instead of text.
I tried to encode all strings in utf-8
and wrote such things:
json = json.dumps(j, ensure_ascii=False, encoding="utf-8")
# -*- coding: utf-8 -*-
status = get_text()
obj = {
"status" : status
}
jsonStatus = json.dumps(obj)
Answer the question
In order to leave comments, you need to log in
You need to add the ensure_ascii=False argument to the json.dumps call, like this:
import json
a = 'СЛ-666'
print(json.dumps(a, ensure_ascii=False))
"СЛ-666"
Process finished with exit code 0
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question