MCPcopy Create free account
hub / github.com/3rdparty/libprocess / json

Function json

src/help.cpp:169–191  ·  view source on GitHub ↗

Write the help strings contained in the help process to JSON. The schema looks as follows: { "processes": [ { "id": id, "endpoints": [ { "name" : name, "text" : text }, ... ] }, ... ] }

Source from the content-addressed store, hash-verified

167// ]
168// }
169void json(JSON::ObjectWriter* writer, const Help& help)
170{
171 // We must declare this temporary typedef in order to make the
172 // foreachpair macro happy. Otherwise it interprets the ',' in the
173 // map definition to denote a new parameter in the macro invocation.
174 typedef map<string, string> StringStringMap;
175
176 writer->field("processes", [&help](JSON::ArrayWriter* writer) {
177 foreachpair (const string& id, const StringStringMap& names, help.helps) {
178 writer->element([&id, &names](JSON::ObjectWriter* writer) {
179 writer->field("id", id);
180 writer->field("endpoints", [&names](JSON::ArrayWriter* writer) {
181 foreachpair (const string& name, const string& text, names) {
182 writer->element([&name, &text](JSON::ObjectWriter* writer) {
183 writer->field("name", name);
184 writer->field("text", text);
185 });
186 }
187 });
188 });
189 }
190 });
191}
192
193
194Future<http::Response> Help::help(const http::Request& request)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected