File: JsonTestController.cc

package info (click to toggle)
drogon 1.9.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,096 kB
  • sloc: cpp: 52,222; sh: 249; xml: 20; makefile: 11
file content (24 lines) | stat: -rw-r--r-- 634 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "JsonTestController.h"
#include <json/json.h>

void JsonTestController::asyncHandleHttpRequest(
    const HttpRequestPtr &req,
    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";
        user["c_name"] = "张三";
        array.append(user);
    }
    json["rows"] = array;
    auto resp = HttpResponse::newHttpJsonResponse(json);
    assert(resp->jsonObject().get());
    callback(resp);
}