Commit 3947903f authored by Houtan Bastani's avatar Houtan Bastani

add JSON output for shock_groups

parent 1edc9af7
Pipeline #1126 passed with stage
in 1 minute and 26 seconds
......@@ -635,3 +635,38 @@ ShockGroupsStatement::writeOutput(ostream &output, const string &basename, bool
}
}
}
void
ShockGroupsStatement::writeJsonOutput(ostream &output) const
{
output << R"({"statementName": "shock_groups", "name": ")" << name << R"(", "groups": {)";
bool unique_label = true;
bool printed_group = false;
for (auto it = shock_groups.begin(); it != shock_groups.end(); it++, unique_label = true)
{
for (auto it1 = it+1; it1 != shock_groups.end(); it1++)
if (it->name == it1->name)
{
unique_label = false;
break;
}
if (unique_label)
{
if (printed_group)
output << ", ";
else
printed_group = true;
output << R"("group_name": ")" << it->name << R"(",)"
<< R"("shocks": [)";
for (auto it1 = it->list.begin(); it1 != it->list.end(); it1++)
{
if (it1 != it->list.begin())
output << ", ";
output << R"(")" << *it1 << R"(")";
}
output << "]";
}
}
output << "}}";
}
......@@ -163,6 +163,7 @@ private:
public:
ShockGroupsStatement(group_t shock_groups_arg, string name_arg);
void writeOutput(ostream &output, const string &basename, bool minimal_workspace) const override;
void writeJsonOutput(ostream &output) const override;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment