diff --git a/README.md b/README.md index 9c3a342..8a4142d 100644 --- a/README.md +++ b/README.md @@ -717,7 +717,7 @@ This way of sending Json is great for when the result is below 4KB #include "ArduinoJson.h" -AsyncResponseStream *response = request->beginResponseStream("text/json"); +AsyncResponseStream *response = request->beginResponseStream("application/json"); DynamicJsonBuffer jsonBuffer; JsonObject &root = jsonBuffer.createObject(); root["heap"] = ESP.getFreeHeap(); @@ -1126,7 +1126,7 @@ server.on("/scan", HTTP_GET, [](AsyncWebServerRequest *request){ } } json += "]"; - request->send(200, "text/json", json); + request->send(200, "application/json", json); json = String(); }); ``` diff --git a/src/AsyncJson.h b/src/AsyncJson.h index 4d37062..ec9a63e 100644 --- a/src/AsyncJson.h +++ b/src/AsyncJson.h @@ -57,7 +57,7 @@ class AsyncJsonResponse: public AsyncAbstractResponse { public: AsyncJsonResponse(bool isArray=false): _isValid{false} { _code = 200; - _contentType = "text/json"; + _contentType = "application/json"; if(isArray) _root = _jsonBuffer.createArray(); else diff --git a/src/SPIFFSEditor.cpp b/src/SPIFFSEditor.cpp index a385a97..a84fa87 100644 --- a/src/SPIFFSEditor.cpp +++ b/src/SPIFFSEditor.cpp @@ -477,7 +477,7 @@ void SPIFFSEditor::handleRequest(AsyncWebServerRequest *request){ dir.close(); #endif output += "]"; - request->send(200, "text/json", output); + request->send(200, "application/json", output); output = String(); } else if(request->hasParam("edit") || request->hasParam("download")){ diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp index 48d6df1..cca6b53 100644 --- a/src/WebResponses.cpp +++ b/src/WebResponses.cpp @@ -483,7 +483,7 @@ void AsyncFileResponse::_setContentType(const String& path){ if (path.endsWith(".html")) _contentType = "text/html"; else if (path.endsWith(".htm")) _contentType = "text/html"; else if (path.endsWith(".css")) _contentType = "text/css"; - else if (path.endsWith(".json")) _contentType = "text/json"; + else if (path.endsWith(".json")) _contentType = "application/json"; else if (path.endsWith(".js")) _contentType = "application/javascript"; else if (path.endsWith(".png")) _contentType = "image/png"; else if (path.endsWith(".gif")) _contentType = "image/gif";