8000 Library fails to parse escaped single quote · Issue #2124 · bblanchon/ArduinoJson · GitHub
[go: up one dir, main page]

Skip to content
Library fails to parse escaped single quote  #2124
@zvirja

Description

@zvirja

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" })";

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugv7ArduinoJson 7

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0