mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-11-30 10:47:40 +08:00
19 lines
535 B
C++
Executable File
19 lines
535 B
C++
Executable File
#include "JsonTestController.h"
|
|
#include <json/json.h>
|
|
void JsonTestController::asyncHandleHttpRequest(const HttpRequestPtr& req,const std::function<void (const HttpResponsePtr &)>&callback)
|
|
{
|
|
Json::Value json;
|
|
json["path"]="json";
|
|
json["name"]="json test";
|
|
Json::Value array;
|
|
for(int i=0;i<5;i++)
|
|
{
|
|
Json::Value user;
|
|
user["id"]=i;
|
|
user["name"]="none";
|
|
array.append(user);
|
|
}
|
|
json["rows"]=array;
|
|
auto resp=HttpResponse::newHttpJsonResponse(json);
|
|
callback(resp);
|
|
} |