#include <ArduinoJson.h>
DynamicJsonDocument jsonNodes(2048);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
uint32_t nodeId = 314123123;
// JSON Root Arrat Creation
JsonArray parentArray = jsonNodes.as<JsonArray>();
for (JsonArray::iterator parent = parentArray.begin(); parent != parentArray.end(); ++parent) {
if ((*parent)["nodeId"] == nodeId) {
return;
}
}
JsonArray childArray = jsonNodes.createNestedArray("child");
JsonObject childObject = childArray.createNestedObject();
childObject["nodeId"] = nodeId;
serializeJson(jsonNodes, Serial);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}