Added JSON test case stubs for all class diagram test cases

This commit is contained in:
Bartek Kryza
2023-03-21 00:37:42 +01:00
parent b412f46fb2
commit c59fbfa565
64 changed files with 2189 additions and 1390 deletions

View File

@@ -21,6 +21,15 @@
namespace clanguml::common::model {
using nlohmann::json;
namespace detail {
std::string render_name(std::string name)
{
util::replace_all(name, "##", "::");
return name;
}
} // namespace detail
void to_json(nlohmann::json &j, const source_location &sl)
{
j = json{{"file", sl.file_relative()}, {"line", sl.line()}};
@@ -28,9 +37,10 @@ void to_json(nlohmann::json &j, const source_location &sl)
void to_json(nlohmann::json &j, const element &c)
{
j = json{{"id", std::to_string(c.id())}, {"name", c.name()},
j = json{{"id", std::to_string(c.id())},
{"name", detail::render_name(c.name())},
{"namespace", c.get_namespace().to_string()}, {"type", c.type_name()},
{"display_name", c.full_name(false)}};
{"display_name", detail::render_name(c.full_name(false))}};
if (const auto &comment = c.comment(); comment)
j["comment"] = comment.value();