JSON::Object stringify unicode to UTF8 format but parser can not handle it #4707
Replies: 5 comments
-
This string is not UTF8 string, that is an escaped string you have to unescape before to obtain the UTF8 string, something like |
Beta Was this translation helpful? Give feedback.
-
@micheleselea It seems not to work for the following case: TEST(JSONParser, TestUnicode)
try
{
String json_str = R"json({"default":"\u0007\u0007"})json";
auto json_str_unescape = Poco::UTF8::unescape(json_str);
Poco::JSON::Parser parser;
Poco::Dynamic::Var result = parser.parse(json_str);
const auto & obj = result.extract<Poco::JSON::Object::Ptr>();
auto default_val = obj->get("default");
Poco::JSON::Object::Ptr json = new Poco::JSON::Object();
json->set("default", default_val);
std::stringstream ss;
json->stringify(ss);
std::cout << ss.str() << std::endl;
ASSERT_TRUE(ss.str() == json_str_unescape);
}
CATCH The json generated by https://go.dev/play/p/6o6kX0vOIsW |
Beta Was this translation helpful? Give feedback.
-
@Lloyd-Pottiger of course it works. I'm not quite sure what the complaint is here. I'l move it to discussions |
Beta Was this translation helpful? Give feedback.
-
and this one works, too: |
Beta Was this translation helpful? Give feedback.
-
@aleks-f I found my poco version is too old, after upgrading to the latest, it works. Thanks very much~ |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior. If feasible, please provide a SSCCE - usually, it will make the process much easier and faster.
Expected behavior
A clear and concise description of what you expected to happen.
Logs
If applicable, add logs to help explain your problem.
Screenshots
If applicable, add screenshots to help explain your problem.
Please add relevant environment information:
Additional context
Add any other context about the problem here.
Beta Was this translation helpful? Give feedback.
All reactions