mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-15 19:42:12 +02:00
Support NUL inside string values (issue #1646)
This commit is contained in:
@ -45,3 +45,13 @@ TEST_CASE("serialize JsonObject to std::string") {
|
||||
REQUIRE("{\r\n \"key\": \"value\"\r\n}" == json);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("serialize an std::string containing a NUL") {
|
||||
StaticJsonDocument<256> doc;
|
||||
doc.set(std::string("hello\0world", 11));
|
||||
CHECK(doc.memoryUsage() == 12);
|
||||
|
||||
std::string json;
|
||||
serializeJson(doc, json);
|
||||
CHECK("\"hello\\u0000world\"" == json);
|
||||
}
|
||||
|
Reference in New Issue
Block a user