Skip to content

Using auto type to access array nested in object crashes device #1120

@prototypicalpro

Description

@prototypicalpro

Description
Running the following code snippet works great:

StaticJsonDocument<500> doc;
constexpr char str[] = "{\"contents\":[{\"module\":\"Packet\"},{\"module\":\"Analog\"}]}";
deserializeJson(doc, str);
JsonObject sensor = thing["contents"][1];
Serial.println(sensor.isNull()); // <- prints "0"

however, changing the type to auto causes my device to hang:

StaticJsonDocument<500> doc;
constexpr char str[] = "{\"contents\":[{\"module\":\"Packet\"},{\"module\":\"Analog\"}]}";
deserializeJson(doc, str);
auto sensor = thing["contents"][1];
Serial.println(sensor.isNull()); // <- Never printed, and must be reset to continue

I suspect this issue is due to ElementProxy type not resolving properly, but am unsure why this would be causing the device to crash.

Platform
I am using ArduinoJson 6.12.0, Arduino IDE 1.8.10, and running this sketch on the Adafruit Feather M0 (SAMD21) with Adafruit SAMD Core 1.5.2 . I've attached the
relevant sketch, as well as the build log.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugv6ArduinoJson 6

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions