Changed widget "name" to "type" in config JSON

This commit is contained in:
2026-06-30 15:58:57 +03:00
parent 7b13f45bd3
commit d9f0554a9a
2 changed files with 8 additions and 8 deletions

View File

@@ -6,7 +6,7 @@
"widgets": "widgets":
[ [
{ {
"name": "widget_name", "type": "widget_type",
"parameter1": "example", "parameter1": "example",
"parameter2": 10 "parameter2": 10
} }

View File

@@ -102,22 +102,22 @@ int main(int argc, char **argv)
for (const json& j : widgets_cfg) for (const json& j : widgets_cfg)
{ {
string widget_name; string widget_type;
json_extract(j, "name", widget_name); json_extract(j, "type", widget_type);
if (widget_name.empty()) if (widget_type.empty())
{ {
continue; continue;
} }
// Check if name exists in known builders // Check if type exists in known builders
if (0 == widget_builders.count(widget_name)) if (0 == widget_builders.count(widget_type))
{ {
cout << "Unknown widget '" << widget_name << "'. Skipping ..." << endl; cout << "Unknown widget '" << widget_type << "'. Skipping ..." << endl;
continue; continue;
} }
// Construct and add widget to vector // Construct and add widget to vector
shared_ptr<Widget> widget = widget_builders[widget_name](j); shared_ptr<Widget> widget = widget_builders[widget_type](j);
if (nullptr != widget) if (nullptr != widget)
{ {
widgets.push_back(widget); widgets.push_back(widget);