convert Json::Value to HttpViewData

1 Relevant Page: Insertasstring
behnamsabaghi 4 months ago

Is there a way to convert Json::Value to HttpViewData ?

antao2002 4 months ago

You can store any type of data into HttpViewData, for example:

Json::Value j;
j["message"]="hello, world";
HttpViewData data;
data.insert("json",std::move(j));
callback(HttpResponse::newHttpViewResponse("json.csp", data);

and then you could get the json object in the json.csp file:

<%c++ 
auto j=@@.get<Json::Value>("json");
...
%>
Log in to comment