因此,我在更新JSON OUT的同时对此进行了更新,但是JSON后跟一个INT
{“ function”:“ timereport”,“ values”:545028} 41
#include <ArduinoJson.h>
char owner[] = "";
const int capacity = JSON_OBJECT_SIZE(2);
DynamicJsonDocument doc(capacity);
void setup() {
Serial.begin(115200);
}
void loop() {
doc["function"]="timereport";
doc["values"]=millis();
Serial.println(serializeJson(doc, Serial));
delay(5000);
}
char json_string[256];
http.begin("http://192.168.1.103:2000/hydroapi"); //Specify destination for HTTP request
http.addHeader("Content-Type","application/json");
doc["function"]="timereport";
doc["values"]=millis();
serializeJson(doc, json_string);
int httpResponseCode = http.POST(json_string); //Send the actual POST request
http.end();
答案 0 :(得分:0)
对serializeJson
的调用将json打印到Serial
(因为这是您传入的流),并返回打印的字节数,然后使用Serial.println
显式打印。
删除对Serial.println
的调用以避免打印字节数,只需调用serializeJson(doc, Serial);