Refactored and unified JSON generators output (#223)

This commit is contained in:
Bartek Kryza
2023-12-27 22:04:02 +01:00
parent edfaabd4fa
commit 9d73c9e3ff
47 changed files with 533 additions and 341 deletions

View File

@@ -42,7 +42,7 @@ void to_json(nlohmann::json &j, const element &c)
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", detail::render_name(c.full_name(false))}};
{"display_name", detail::render_name(c.full_name(true))}};
if (const auto &comment = c.comment(); comment)
j["comment"] = comment.value();

View File

@@ -35,13 +35,13 @@
namespace clanguml::common::model {
using nlohmann::json;
void to_json(nlohmann::json &j, const source_location &sl);
void to_json(json &j, const source_location &sl);
void to_json(nlohmann::json &j, const element &c);
void to_json(json &j, const element &c);
void to_json(nlohmann::json &j, const template_parameter &c);
void to_json(json &j, const template_parameter &c);
void to_json(nlohmann::json &j, const relationship &c);
void to_json(json &j, const relationship &c);
} // namespace clanguml::common::model
namespace clanguml::common::generators::json {

View File

@@ -123,8 +123,11 @@ public:
*
* @return Fully qualified elements name.
*/
std::string full_name(bool /*relative*/) const override
std::string full_name(bool relative) const override
{
if (relative)
return name();
return name_and_ns();
}