MCPcopy Create free account
hub / github.com/MITK/MITK / to_json

Method to_json

Modules/Forms/src/mitkForm.cpp:323–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void mitk::Forms::to_json(nlohmann::ordered_json& j, const Form& f)
324{
325 j["FileFormat"] = "MITK Form";
326 j["Version"] = 1;
327
328 const int numberOfSections = f.GetNumberOfSections();
329
330 for (int index = 0; index < numberOfSections; ++index)
331 {
332 const auto& section = f.GetSection(index);
333 ordered_json jSection;
334
335 if (auto title = section.GetTitle(); !title.empty())
336 jSection["Title"] = title;
337
338 if (auto description = section.GetDescription(); !description.empty())
339 jSection["Description"] = description;
340
341 for (const auto* question : section.GetQuestions())
342 {
343 ordered_json jQuestion;
344 question->ToJSON(jQuestion);
345
346 jSection["Questions"].push_back(jQuestion);
347 }
348
349 j["Sections"].push_back(jSection);
350 }
351}

Callers

nothing calls this directly

Calls 6

GetNumberOfSectionsMethod · 0.80
GetQuestionsMethod · 0.80
GetTitleMethod · 0.45
emptyMethod · 0.45
GetDescriptionMethod · 0.45
ToJSONMethod · 0.45

Tested by

no test coverage detected