Skip to content

Commit 59fcdfb

Browse files
committed
Merge pull request peritus#19 from terryyin/master
Make the Chinese stringify result readable.
2 parents 16a5510 + 20e5ecb commit 59fcdfb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/HttpLibrary/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def stringify_json(self, data):
547547
"""
548548

549549
try:
550-
return json.dumps(data)
550+
return json.dumps(data, ensure_ascii=False)
551551
except ValueError, e:
552552
raise ValueError(
553553
"Could not stringify '%r' to JSON: %s" % (data, e))
@@ -618,7 +618,7 @@ def log_json(self, json_string, log_level='INFO'):
618618
"""
619619
Logs a pretty printed version of the JSON document `json_string`.
620620
"""
621-
for line in json.dumps(json_string, indent=2).split('\n'):
621+
for line in json.dumps(json_string, indent=2, ensure_ascii=False).split('\n'):
622622
logger.write(line, log_level)
623623

624624
# debug

tests/json.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ Stringify Complex Object
109109

110110
Should Be Equal As Strings ${json_string} {"a": "1", "b": "12", "names": ["First Name", "Family Name", "Email"]}
111111

112+
Stringify Data With Chinese String
113+
Set Test Variable ${data} 中
114+
${json_string}= Stringify JSON ${data}
115+
Should Be Equal As Strings ${json_string} "${data}"
116+
112117
Get Json Value In Chinese OK
113118
Set Test Variable ${chinese} "中"
114119
${result}= Get Json Value {"foo":${chinese}} /foo

0 commit comments

Comments
 (0)