Skip to content

Values of json structure disappear after the first time. #1187

@nvecchio1

Description

@nvecchio1

Hi,
i'm using ArduinoJson V6 to programming my esp32 with Platform.io.
Here my code:

const int capacity = JSON_ARRAY_SIZE(2) + 4 * JSON_OBJECT_SIZE(2);
StaticJsonDocument<capacity> doc;
// Add the "location" object
JsonObject location = doc.createNestedObject("location");
location["lat"] = 48.748010;
location["lon"] = 2.293491;
// Add the "feeds" array
JsonArray feeds = doc.createNestedArray("feeds");
JsonObject feed1 = feeds.createNestedObject();
feed1["key"] = "a1";
feed1["value"] = 2345;
JsonObject feed2 = feeds.createNestedObject();
feed2["key"] = "a2";
feed2["value"] = 2443;
Serial.println();
serializeJsonPretty(doc, Serial);

delay(5000);

When i running the program, the values are good. But at the second time the structure of json is empty , there are only name of json object nested in doc.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions