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":
[
{
"name": "widget_name",
"type": "widget_type",
"parameter1": "example",
"parameter2": 10
}

View File

@@ -102,22 +102,22 @@ int main(int argc, char **argv)
for (const json& j : widgets_cfg)
{
string widget_name;
json_extract(j, "name", widget_name);
if (widget_name.empty())
string widget_type;
json_extract(j, "type", widget_type);
if (widget_type.empty())
{
continue;
}
// Check if name exists in known builders
if (0 == widget_builders.count(widget_name))
// Check if type exists in known builders
if (0 == widget_builders.count(widget_type))
{
cout << "Unknown widget '" << widget_name << "'. Skipping ..." << endl;
cout << "Unknown widget '" << widget_type << "'. Skipping ..." << endl;
continue;
}
// 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)
{
widgets.push_back(widget);