Function makeJson

Synopsis

#include <orm_lib/inc/drogon/orm/RestfulController.h>

template <typename T>
Json::Value makeJson(const HttpRequestPtr &req, const T &obj)

Description

No description yet.

Source

Lines 110-139 in orm_lib/inc/drogon/orm/RestfulController.h.

template <typename T>
Json::Value makeJson(const HttpRequestPtr &req, const T &obj)
{
    auto &queryParams = req->parameters();
    auto iter = queryParams.find("fields");
    if (masquerading_)
    {
        if (iter != queryParams.end())
        {
            auto fields = utils::splitStringToSet(iter->second, ",");
            return obj.toMasqueradedJson(fieldsSelector(fields));
        }
        else
        {
            return obj.toMasqueradedJson(masqueradingVector_);
        }
    }
    else
    {
        if (iter != queryParams.end())
        {
            auto fields = utils::splitString(iter->second, ",");
            return obj.toMasqueradedJson(fields);
        }
        else
        {
            return obj.toJson();
        }
    }
}





Add Discussion as Guest

Log in to DocsForge