提问者:小点点

C++中的Json序列化(esp32)


我正在为esp32编写一些脚本,并努力序列化一个JSON。

使用的库是HTTPClient和ArduInoJson。

String payload = http.getString();
Serial.println(payload);
deserializeJson(result, payload);
const char* usuario = result["user"];
Serial.println("##########");
Serial.println(usuario);

接收到的有效载荷为:

null

null

有没有人可以帮助我如何正确地从“用户”对象中获取“id”和“text”值?

谢啦!


共2个答案

匿名用户

有人能帮助我如何正确地从“User”对象获取“ID”和“Text”值吗?您可以使用

const char *id = result["user"]["id"];
const char *text = result["user"]["text"];

匿名用户

尝试:

const int id = result["user"]["id"];
const char* text = result["user"]["text"];

相关问题


MySQL Query : SELECT * FROM v9_ask_question WHERE 1=1 AND question regexp '(c++|中|json|序列化|esp32)' ORDER BY qid DESC LIMIT 20
MySQL Error : Got error 'repetition-operator operand invalid' from regexp
MySQL Errno : 1139
Message : Got error 'repetition-operator operand invalid' from regexp
Need Help?