Open luprochazka-cen63872 opened 1 year ago
Hi,
indeed, for some reason we are getting Utf-16 instead of Utf-8 encoded data from json.dumps.
Like this German umlaut: json.dumps({"test":"über"})
results in '{"test": "\\u00fcber"}'
.
Here is a test for this issue:
*** Settings ***
Library JSONLibrary
*** Test Cases ***
Test_Conversion short
${data} = Set Variable "{'test':'über'}"
${json} = Convert String To Json ${data}
${string} = Convert Json To String ${json}
# Issue: "{'test':'\u00fcber'}" != "{'test':'über'}"
Should Be Equal ${string} ${data}
I created a PR here as a workaround to forward the ensure_ascii parameter to json.dumps: https://github.com/robotframework-thailand/robotframework-jsonlibrary/pull/60
Regards, Michael
Function convert_json_to_string returns wrong encoding if you use UTF-8. I have workaround:
` @staticmethod def convert_json_to_string(json_object): """Convert JSON object to string