This repository was archived by the owner on Jan 20, 2025. It is now read-only.
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
Document how to parse JSON POSTed to the ESP #195
Open
Description
How do we parse JSON POSTed to the ESP, i.e., what is the ESPAsyncWebServer equivalent of esp8266/Arduino#1321 (comment)
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(server.arg("plain"));
?
The following educated guess, jsonBuffer.parseObject(request->getParam("plain", true)->value());
, seems not to work for me:
server.on("/api/printer/command", HTTP_POST, [](AsyncWebServerRequest * request) {
const size_t bufferSize = JSON_OBJECT_SIZE(1) + 250;
DynamicJsonBuffer jsonBuffer(bufferSize);
JsonObject& root = jsonBuffer.parseObject(request->getParam("plain", true)->value());
const char* command = root["command"];
request->send(204);
});
Is this documented somewhere? If not, please document it.