Ejemplo mínimo de serialización con ArduinoJson para servidor web HTTP de ESP-IDF

esp_http_handler.cpp
static const httpd_uri_t valueHandler = {
    .uri       = "/api/value",
    .method    = HTTP_GET,
    .handler   = [](httpd_req_t *req) {
        httpd_resp_set_type(req, "application/json");
        // create json document
        DynamicJsonDocument json(1024);
        json["value"] = 1.0;
        // Serializar JSON a string
        std::string buf;
        serializeJson(json, buf);
        // Enviar respuesta
        httpd_resp_send(req, buf.c_str(), buf.length());
        return ESP_OK;
    }
};

Para añadir ArduinoJson a PlatformIO, añade el siguiente lib_deps a platformio.ini:

platformio.ini
lib_deps =
    ArduinoJSON@6.17.2

Echa un vistazo a artículos similares por categoría: Arduino ESP8266/ESP32