use array instead of hash for dumpconfig json and add circuit

This commit is contained in:
John
2022-01-08 15:19:26 +01:00
parent c14f934837
commit d00f6d755c
+9 -4
View File
@@ -2798,7 +2798,7 @@ void MessageMap::dump(bool withConditions, OutputFormat outputFormat, ostream* o
bool first = true; bool first = true;
bool isJson = (outputFormat & OF_JSON) != 0; bool isJson = (outputFormat & OF_JSON) != 0;
if (isJson) { if (isJson) {
*output << "{"; *output << (m_addAll ? "[" : "}");
} else { } else {
Message::dumpHeader(nullptr, output); Message::dumpHeader(nullptr, output);
} }
@@ -2821,9 +2821,14 @@ void MessageMap::dump(bool withConditions, OutputFormat outputFormat, ostream* o
*output << endl; *output << endl;
} }
if (isJson) { if (isJson) {
if (!wasFirst) {
*output << ",\n";
}
ostringstream str; ostringstream str;
message->decodeJson(!wasFirst, true, false, false, outputFormat, &str); message->decodeJson(false, false, false, false, outputFormat, &str);
*output << str.str(); string add = str.str();
size_t pos = add.find('{');
*output << "\n {\"circuit\": \"" << message->getCircuit() << "\", " << add.substr(pos+1);
} else { } else {
message->dump(nullptr, withConditions, outputFormat, output); message->dump(nullptr, withConditions, outputFormat, output);
} }
@@ -2849,7 +2854,7 @@ void MessageMap::dump(bool withConditions, OutputFormat outputFormat, ostream* o
} }
} }
if (isJson) { if (isJson) {
*output << "}" << endl; *output << (m_addAll ? "]" : "}") << endl;
} else { } else {
if (!first) { if (!first) {
*output << endl; *output << endl;