PEL: user header in JSON

The PELTool application is able to convert sections to JSON. This commit
takes care of converting the user header section to JSON.

user header section in JSON sample:

"User Header":[
 {"Section Version": "1"},
 {"Sub-section type": "0"},
 {"Log Committed by": "0x2000"},
 {"Subsystem": "bmc_firmware"},
 {"Event Scope": "entire_platform"},
 {"Event Severity":"unrecoverable"},
 {"Event Type": "na"}
]

Signed-off-by: Aatir Manzur <aatrapps@gmail.com>
Change-Id: I0dca1d87019b9e62d711ee6d034f2e8bc0574c2e
diff --git a/extensions/openpower-pels/pel.cpp b/extensions/openpower-pels/pel.cpp
index babc61b..2345e0e 100644
--- a/extensions/openpower-pels/pel.cpp
+++ b/extensions/openpower-pels/pel.cpp
@@ -206,21 +206,30 @@
 void PEL::printSectionInJSON(const Section& section, std::string& buf) const
 {
     char tmpB[5];
+    uint8_t id[] = {static_cast<uint8_t>(section.header().id >> 8),
+                    static_cast<uint8_t>(section.header().id)};
+    sprintf(tmpB, "%c%c", id[0], id[1]);
+    std::string sectionID(tmpB);
+    std::string sectionName = pv::sectionTitles.count(sectionID)
+                                  ? pv::sectionTitles.at(sectionID)
+                                  : "Unknown Section";
     if (section.valid())
     {
-        uint8_t id[] = {static_cast<uint8_t>(section.header().id >> 8),
-                        static_cast<uint8_t>(section.header().id)};
-        sprintf(tmpB, "%c%c", id[0], id[1]);
-        std::string sectionID(tmpB);
-        std::string sectionName = pv::sectionTitles.count(sectionID)
-                                      ? pv::sectionTitles.at(sectionID)
-                                      : "Unknown Section";
-        buf += "\n\"" + sectionName + "\":[\n ";
-        std::vector<uint8_t> data;
-        Stream s{data};
-        section.flatten(s);
-        std::string dstr = dumpHex(std::data(data), data.size());
-        buf += dstr + "\n],\n";
+        auto json = section.getJSON();
+        if (json)
+        {
+            buf += "\n\"" + sectionName + "\":[\n ";
+            buf += *json + "\n],\n";
+        }
+        else
+        {
+            buf += "\n\"" + sectionName + "\":[\n ";
+            std::vector<uint8_t> data;
+            Stream s{data};
+            section.flatten(s);
+            std::string dstr = dumpHex(std::data(data), data.size());
+            buf += dstr + "],\n";
+        }
     }
     else
     {