-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Describe the bug
Library fails to parse JSON when using single quotes for JSON structure and escaping it inside the value. I know that it's a bit weird to use single quote for JSON elements, but that's what HomeAssistant & ESPHome are doing 😢
Troubleshooter report
Irrelevant
Environment
Here is the environment that I used:
- Microcontroller: ESP8266, ESP32
- Core/runtime: ESPHome
Reproduction
Here is a small snippet that reproduces the issue.
auto json = R"({ 'summary': 'a\'b' })"
ArduinoJson::JsonDocument doc;
auto res = ArduinoJson::deserializeJson(doc, json);
auto summary = doc.as<ArduinoJson::JsonObject>()["summary"].as<std::string>();
Program output
Expected output:
res: OK
summary: a'b
Actual output:
res: InvalidInput
summary: null
Note:
It works when using double-quotes and escape those:
auto json = R"({ "summary": "x a\"b y" })";