From 2ca0b3ea9b345491b67f0fb9afe9915d3e390984 Mon Sep 17 00:00:00 2001 From: Matthew Frost Date: Tue, 13 Jun 2023 12:57:40 +0200 Subject: [PATCH] proper json --- include/main.h | 2 +- src/main.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/main.h b/include/main.h index 693c6d6..b7d9e12 100644 --- a/include/main.h +++ b/include/main.h @@ -15,7 +15,7 @@ #include #endif #ifdef WEB_OTA_UPDATE - #include + #include #endif #endif diff --git a/src/main.cpp b/src/main.cpp index 9b65884..9cb865e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,13 +159,13 @@ String processor(const String& var){ if(request->hasParam("cardId", true)) {} //This is important, otherwise the sketch will crash if there is no body else { - AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No cardId'}"); + AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No cardId\"}"); request->send(response); } if(request->hasParam("desc", true)) {} //This is important, otherwise the sketch will crash if there is no body else { - AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No desc'}"); + AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No desc\"}"); request->send(response); } @@ -173,7 +173,7 @@ String processor(const String& var){ String desc = String(request->arg("desc")); if (acl.validateAccess(String(cardId))) { - AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'Duplicate ACL'}"); + AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"Duplicate ACL\"}"); request->send(response); } else { acl.addUser(cardId, desc); @@ -190,19 +190,19 @@ String processor(const String& var){ if(request->hasParam("cardId", true)) {} //This is important, otherwise the sketch will crash if there is no body else { - AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No cardId'}"); + AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No cardId\"}"); request->send(response); } if(request->hasParam("newCardId", true)) {} //This is important, otherwise the sketch will crash if there is no body else { - AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No newCardId'}"); + AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "\"msg\":\"No newCardId\"}"); request->send(response); } if(request->hasParam("desc", true)) {} //This is important, otherwise the sketch will crash if there is no body else { - AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No desc'}"); + AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No desc\"}"); request->send(response); } String cardId = String(request->arg("cardId")); @@ -220,7 +220,7 @@ String processor(const String& var){ if(request->hasParam("cardId", true)) {} //This is important, otherwise the sketch will crash if there is no body else { - AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{'msg':'No cardId'}"); + AsyncWebServerResponse *response = request->beginResponse(400, "application/json", "{\"msg\":\"No cardId\"}"); request->send(response); } String cardId = String(request->arg("cardId")); @@ -337,7 +337,7 @@ void setup() { }); server.onNotFound([](AsyncWebServerRequest *request){ - request->send(200, "application/json", "{'msg':'The content you are looking for was not found'}"); + request->send(200, "application/json", "{\"msg\":\"The content you are looking for was not found\"}"); }); // Send a GET request to /gpio?output=&state=