pldmtool: platform: getpdr: form proper JSON
Separate records with commas and wrap in an array so we get a parseable
json document for tools like pldm_visualize_pdrs.py. It doesn't look
pretty - for example:
}
,{
but it isn't clear how to improve the situation without significant
refactoring.
Change-Id: I6484e6d2b479adeb942ec802094adab6e12f783f
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/pldmtool/pldm_platform_cmd.cpp b/pldmtool/pldm_platform_cmd.cpp
index aac669a..6945285 100644
--- a/pldmtool/pldm_platform_cmd.cpp
+++ b/pldmtool/pldm_platform_cmd.cpp
@@ -99,6 +99,9 @@
pdrRecType.begin(), tolower);
}
+ // start the array
+ std::cout << "[\n";
+
// Retrieve all PDR records starting from the first
recordHandle = 0;
uint32_t prevRecordHandle = 0;
@@ -126,7 +129,16 @@
return;
}
prevRecordHandle = recordHandle;
+
+ if (recordHandle != 0)
+ {
+ // close the array
+ std::cout << ",";
+ }
} while (recordHandle != 0);
+
+ // close the array
+ std::cout << "]\n";
}
else
{