You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is currently now feature implemented to do this. It could be added as additional parameter to the dump function. In Python's json.dump function, there is a parameter ensure_ascii for this:
If ensure_ascii is true (the default), all non-ASCII characters in the output are escaped with \uXXXX sequences, and the result is a str instance consisting of ASCII characters only. If ensure_ascii is false, some chunks written to fp may be unicode instances. This usually happens because the input contains unicode strings or the encoding parameter is used. Unless fp.write() explicitly understands unicode (as in codecs.getwriter()) this is likely to cause an error.
Internally, function escape_string needs to be changed for this. It currently only escapes control characters to \uxxxx.
example:
json js = json::parse(R"({ "escaped" : "\u6211\u662f\u4e2d\u56fd\u4eba" })"); std::cout << js.dump() << std::endl;
result (as utf-8):
{"escaped":"我是中国人"}
question:
How can I get the same result as the entered string?
such as:
{"escaped":"\u6211\u662f\u4e2d\u56fd\u4eba"}
The text was updated successfully, but these errors were encountered: