#include <ArduinoJson.h>

void sendJson()
{
    DynamicJsonDocument jsonDoc(500);

    jsonDoc["sender"] = "themometer";
    jsonDoc["receiver"] = "webserver";
    jsonDoc["topic"] = "thermometer-sensor-data";
    jsonDoc["temperature"] = 2;

    String jsonText;
    serializeJson(jsonDoc, jsonText);

    Serial1.print(jsonText);
}

void setup()
{
    Serial.begin(115200);
    Serial1.begin(115200);

    sendJson();
}

void loop()
{
    while (Serial1.available() > 0)
    {
        Serial.print((char)Serial1.read());
        return;
    }

    // Increase this to 100ms to break it
    delay(10);
}
Loading chip...chip-uart-json