Skip to content
This repository was archived by the owner on Mar 5, 2026. It is now read-only.

Commit fc71230

Browse files
merlinschumacherme-no-dev
authored andcommitted
Change JSON MIME type to application/json (me-no-dev#311)
1 parent 1078e91 commit fc71230

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ This way of sending Json is great for when the result is below 4KB
717717
#include "ArduinoJson.h"
718718

719719

720-
AsyncResponseStream *response = request->beginResponseStream("text/json");
720+
AsyncResponseStream *response = request->beginResponseStream("application/json");
721721
DynamicJsonBuffer jsonBuffer;
722722
JsonObject &root = jsonBuffer.createObject();
723723
root["heap"] = ESP.getFreeHeap();
@@ -1126,7 +1126,7 @@ server.on("/scan", HTTP_GET, [](AsyncWebServerRequest *request){
11261126
}
11271127
}
11281128
json += "]";
1129-
request->send(200, "text/json", json);
1129+
request->send(200, "application/json", json);
11301130
json = String();
11311131
});
11321132
```

src/AsyncJson.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class AsyncJsonResponse: public AsyncAbstractResponse {
5757
public:
5858
AsyncJsonResponse(bool isArray=false): _isValid{false} {
5959
_code = 200;
60-
_contentType = "text/json";
60+
_contentType = "application/json";
6161
if(isArray)
6262
_root = _jsonBuffer.createArray();
6363
else

src/SPIFFSEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ void SPIFFSEditor::handleRequest(AsyncWebServerRequest *request){
477477
dir.close();
478478
#endif
479479
output += "]";
480-
request->send(200, "text/json", output);
480+
request->send(200, "application/json", output);
481481
output = String();
482482
}
483483
else if(request->hasParam("edit") || request->hasParam("download")){

src/WebResponses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void AsyncFileResponse::_setContentType(const String& path){
483483
if (path.endsWith(".html")) _contentType = "text/html";
484484
else if (path.endsWith(".htm")) _contentType = "text/html";
485485
else if (path.endsWith(".css")) _contentType = "text/css";
486-
else if (path.endsWith(".json")) _contentType = "text/json";
486+
else if (path.endsWith(".json")) _contentType = "application/json";
487487
else if (path.endsWith(".js")) _contentType = "application/javascript";
488488
else if (path.endsWith(".png")) _contentType = "image/png";
489489
else if (path.endsWith(".gif")) _contentType = "image/gif";

0 commit comments

Comments
 (0)