From e07a3934859f91c8e233b2ee855132404b23bded Mon Sep 17 00:00:00 2001 From: EntireTwix Date: Fri, 18 Jun 2021 13:50:47 -0700 Subject: [PATCH] :bug: added JsonCast back --- src/bank_f.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/bank_f.cpp b/src/bank_f.cpp index 7909b82..08f30fd 100644 --- a/src/bank_f.cpp +++ b/src/bank_f.cpp @@ -1,9 +1,29 @@ #include "bank_f.h" -#define JSON(V) callback(HttpResponse::newHttpJsonResponse(V)); -#define INLINE __attribute__((always_inline)) inline +#define JSON(V) callback(HttpResponse::newHttpJsonResponse(JsonCast(V))); #define PASS_HEADER req->getHeader("Password") +template +constexpr Json::Value JsonCast(T &&val) +{ + if constexpr (std::is_same_v) + { + return (int)val; //becuase of json lib interpreting 67 as 'A' for example + } + else if constexpr (std::is_same_v) + { + return (Json::Int64)val; + } + else if constexpr (std::is_same_v) + { + return (Json::Int64)val; + } + else + { + return val; + } +} + BankF::BankF(Bank *b) : bank(*b) {} void BankF::Help(req_args) const