Fix a bug when creating json responses (#373)

This commit is contained in:
An Tao 2020-03-02 23:34:28 +08:00 committed by GitHub
parent 686e30b250
commit 49d1697bec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View File

@ -17,5 +17,6 @@ void JsonTestController::asyncHandleHttpRequest(
}
json["rows"] = array;
auto resp = HttpResponse::newHttpJsonResponse(json);
assert(resp->jsonObject().get());
callback(resp);
}

View File

@ -679,6 +679,10 @@ void HttpResponseImpl::parseJson() const
jsonPtr_.reset();
}
}
else
{
jsonPtr_.reset();
}
}
HttpResponseImpl::~HttpResponseImpl()

View File

@ -304,10 +304,12 @@ class HttpResponseImpl : public HttpResponse
}
void setJsonObject(const Json::Value &pJson)
{
flagForParsingJson_ = true;
jsonPtr_ = std::make_shared<Json::Value>(pJson);
}
void setJsonObject(Json::Value &&pJson)
{
flagForParsingJson_ = true;
jsonPtr_ = std::make_shared<Json::Value>(std::move(pJson));
}
void generateBodyFromJson();

@ -1 +1 @@
Subproject commit b46138e0cd281bc42f061bf9c51755e96ad9f3f6
Subproject commit 4eee8e12def354cbd9745e80a917fd9e71aecb85