I’m writing some script for esp32 and struggling to serialize a json.
Used libraries are HTTPClient and ArduinoJson.
String payload = http.getString();
Serial.println(payload);
deserializeJson(result, payload);
const char* usuario = result["user"];
Serial.println("##########");
Serial.println(usuario);
The received payload is:
{"ip":"10.57.39.137","area":"[{"id":"3","text":"BOX"}]","user":"[{"id":"6270","text":"ANDRE LARA OLIVEIRA E SILVA"}]","teamId":6,"id":4,"siteId":2,"userCreate":"100059527","dateCreate":"2020-11-19T08:49:03.957","userUpdate":null,"dateUpdate":null}
and i need to retrieve id and text from "user" key. Its fine to deserielize and retrieve user object. But result["user"]
returns [{"id":"6270","text":"ANDRE LARA OLIVEIRA E SILVA"}]
to the char array. So it’s something like a json nested to a array… and it’s not working out to deserialize.
Can anyone help me how to properly get the "id" and "text" values from "user" object?
Thanks!
Source: Windows Questions C++