diff --git a/tools.cpp b/tools.cpp index bfbbbcc..b04a7cc 100644 --- a/tools.cpp +++ b/tools.cpp @@ -1601,7 +1601,7 @@ QueryHandler::QueryHandler(string service, cxxtools::http::Request& request) } if ( found_json ) { - jsonObject = jsonParser.Parse(body); + jsonObject.reset(jsonParser.Parse(body)); esyslog("restfulapi: JSON parsed successfully: %s", jsonObject == NULL ? "no" : "yes"); } else { _body.parse_url(body); @@ -1617,13 +1617,6 @@ QueryHandler::QueryHandler(string service, cxxtools::http::Request& request) if ( (int)_url.find(".html") != -1 ) { _format = ".html"; } } -QueryHandler::~QueryHandler() -{ - if (jsonObject != NULL) { - delete jsonObject; - } -} - /** * fix wrong decoded urls */ diff --git a/tools.h b/tools.h index 1e056c9..ca38f5e 100644 --- a/tools.h +++ b/tools.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -268,7 +269,7 @@ class QueryHandler cxxtools::QueryParams _options; cxxtools::QueryParams _body; JsonParser jsonParser; - JsonObject* jsonObject; + std::shared_ptr jsonObject; std::string fixUrl(std::string url); void parseRestParams(std::string params); std::string getJsonString(std::string name); @@ -277,7 +278,6 @@ class QueryHandler std::string _format; public: QueryHandler(std::string service, cxxtools::http::Request& request); - ~QueryHandler(); bool has(std::string name); bool hasJson(std::string name); bool hasOption(std::string name);