I can not get data
Created by: ghost
Hi, BBlanchon!
I need help. Use ESP8285.
void onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t * data, size_t len) {
if (type == WS_EVT_DATA) {
Serial.println((char*)data); // I get a valid package (as below)
DynamicJsonDocument doc;
DeserializationError error = deserializeJson(doc, (char*)data);
if (error) {
Serial.println("Error Pack");
return;
}
JsonObject root = doc.as<JsonObject>();
if (root["setSC"]) {
Serial.println(root["setSC"]); // I get nothing???
}
}
}
This is the received package from websocket:
{"setSC":
[
{
"ID":0,
"NM":"-= 0 =-",
"EN":false,
"AP":"10",
"EV":[{"da":"82894F","pr":[[0,5],[0,4]]}],
"AC":[{"da":"82894F","pr":[[3,2],[0,2]]}]
},
{
"ID":1,
"NM":"-= 1 =-",
"EN":true,
"AP":"12",
"EV":[{"da":"82894F","pr":[[1,3],[0,0]]}],
"AC":[{"da":"82894F","pr":[[2,3],[0,4]]}]
}
]
}
I need to get only an array belonging to "setSC" How do I get the whole array?