14 #include <nlohmann/json.hpp>
16 using json = nlohmann::json;
110#define JSON JsonRequestHelper
Forward declaration for potential routing needs.
Utility class for working with JSON content in HTTP requests.
static std::string getString(const HttpRequest &req, const std::string &key)
Get a string value from the request body.
static bool getBool(const HttpRequest &req, const std::string &key, bool def=false)
Get a boolean value from the request body.
static json getJsonValue(const HttpRequest &req, const std::string &path)
Extract a nested JSON value using a dot-separated path (e.g., "user.name").
static json parseJsonBody(const HttpRequest &req)
Parse the raw body into a JSON object.
static int getInt(const HttpRequest &req, const std::string &key, int def=0)
Get an integer value from the request body.
static json getArray(const HttpRequest &req, const std::string &key)
Get a JSON array from the request body.
static bool hasField(const HttpRequest &req, const std::string &key)
Check if a JSON field exists.
static json getFullJson(const HttpRequest &req)
Parse and return the full JSON body from the request.
static double getDouble(const HttpRequest &req, const std::string &key, double def=0.0)
Get a double value from the request body.
static json getObject(const HttpRequest &req, const std::string &key)
Get a JSON object from the request body.