fixed memory allocation
This commit is contained in:
parent
9577d02c57
commit
c22de68ffd
1 changed files with 10 additions and 3 deletions
|
@ -38,22 +38,29 @@ class ACLWebServerClass{
|
|||
}
|
||||
}
|
||||
// Create a JSON array to store the users
|
||||
DynamicJsonDocument jsonDoc(ESP.getMaxAllocHeap());
|
||||
DynamicJsonDocument jsonDoc(1024);
|
||||
Serial.println(jsonDoc.capacity());
|
||||
JsonArray usersArray = jsonDoc.to<JsonArray>();
|
||||
|
||||
// Retrieve the ACL data using the getter function
|
||||
const User* aclData = acl.getACL();
|
||||
|
||||
// Iterate over each user in the ACL and add it to the JSON array
|
||||
Serial.println("GET /users");
|
||||
Serial.println("Sending users list");
|
||||
Serial.println("Users list:");
|
||||
|
||||
for (int i = 0; i < acl.getACLSize(); i++) {
|
||||
JsonObject user = usersArray.createNestedObject();
|
||||
user["cardId"] = aclData[i].cardId;
|
||||
user["desc"] = aclData[i].desc;
|
||||
user["desc"] = aclData[i].desc;
|
||||
Serial.println("Card: " + aclData[i].cardId + " Desc: " + aclData[i].desc);
|
||||
}
|
||||
|
||||
|
||||
// Convert the JSON array to a string
|
||||
String response;
|
||||
serializeJson(usersArray, response);
|
||||
serializeJson(jsonDoc, response);
|
||||
|
||||
// Set the response content type to JSON
|
||||
request->send(200, "application/json", response);
|
||||
|
|
Loading…
Reference in a new issue