Skip to content

Arduino v3.1.2 String crashes on serializeJson #2158

Closed
@Tobi177

Description

@Tobi177

Describe the bug
On the latest Arduino release v3.1.2 the function serializeJson does not work anymore and the app is crashing instantly. Within the Arduino release I see that some changes to the String objects were done: espressif/arduino-esp32#10938 Maybe, around this issue is the reason for the crashes, but that is just an assumption. Switching back to previous releases are working fine again. I rollback to Arduino v3.1.1 and the app is working fine again.

Environment
esp-idf v5.3 and Arduino v3.1.2 as a component
ArduinoJson v7.3.0
esp32, esp32c2

Reproduction

String getAvailableNetworks() {

  JsonDocument json_doc;
  JsonArray networks = json_doc.to<JsonArray>();

  int n = WiFi.scanNetworks(false, false);
  if (n) {
    for (int i = 0; i < n; ++i) {
      JsonObject networkObj = networks.add<JsonObject>();
      networkObj["ssid"] = WiFi.SSID(i);
      networkObj["rssi"] = WiFi.RSSI(i);
      networkObj["authmode"] = (WiFi.encryptionType(i) == WIFI_AUTH_OPEN) ? 0 : 1;
    }
  }

  String json_available_networks;
  serializeJson(json_doc, json_available_networks);  // CRASHES HERE

  return json_available_networks;

}

Only the String handling is affected! Once I use char arrays/pointers the serializeJson work fine on Arduino v3.1.2 as well. Only if strings are serialized the problem occurs. Please report back if any further information are needed. Thank you.

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