Display pldmtool Base & Bios command output in JSON.

./pldmtool base GetPLDMTypes
[
    {
        "PLDM Type": "base",
        "PLDM Type Code": 0
    },
    {
        "PLDM Type": "platform",
        "PLDM Type Code": 2
    },
    {
        "PLDM Type": "bios",
        "PLDM Type Code": 3
    },
    {
        "PLDM Type": "fru",
        "PLDM Type Code": 4
    },
    {
        "PLDM Type": "oem-ibm",
        "PLDM Type Code": 63
    }
]

./pldmtool base GetPLDMVersion -t 0
{
    "Response": "1.0.0"
}

./pldmtool base GetTID
{
    "Response": 1
}

./pldmtool base GetPLDMCommands -t 0
[
    {
        "PLDM Command Code": 2,
        "PLDM Command": "GetTID"
    },
    {
        "PLDM Command Code": 3,
        "PLDM Command": "GetPLDMVersion"
    },
    {
        "PLDM Command Code": 4,
        "PLDM Command": "GetPLDMTypes"
    },
    {
        "PLDM Command Code": 5,
        "PLDM Command": "GetPLDMCommands"
    }
]

./pldmtool bios GetDateTime
{
    "Response": "2020-10-15 16:33:55"
}

./pldmtool bios GetBIOSTable -t 0
{
    "0": "Allowed",
    "1": "Disabled",
    "2": "Enabled",
    "3": "IPv4DHCP",
    "4": "IPv4Static",
    "5": "Not Allowed",
    "6": "OPAL",
    "7": "Perm",
    "8": "PowerVM",
    "9": "Temp",
    "10": "hb-hyp-switch",
    "11": "pvm-fw-boot-side",
    "12": "pvm-inband-code-update",
    "13": "pvm-os-boot-side",
    "14": "pvm-pcie-error-inject",
    "15": "pvm-stop-at-standby",
    "16": "pvm-surveillance",
    "17": "pvm-system-name",
    "18": "vmi-hostname",
    "19": "vmi-if-count",
    "20": "vmi-if0-ipv4-ipaddr",
    "21": "vmi-if0-ipv4-method",
    "22": "vmi-if0-ipv4-prefix-length",
    "23": "vmi-if1-ipv4-ipaddr",
    "24": "vmi-if1-ipv4-method",
    "25": "vmi-if1-ipv4-prefix-length",
    "26": "vmi-ipv4-gateway"
}

./pldmtool bios GetBIOSTable -t 1
[
    {
        "AttributeHandle": 0,
        "AttributeNameHandle": "17(pvm-system-name)",
        "AttributeType": "BIOSString",
        "StringType": "0x01",
        "MinimumStringLength": 0,
        "MaximumStringLength": 100,
        "DefaultStringLength": 0,
        "DefaultString": ""
    },
...
...
   {
        "AttributeHandle": 16,
        "AttributeNameHandle": "15(pvm-stop-at-standby)",
        "AttributeType": "BIOSEnumeration",
        "NumberOfPossibleValues": 2,
        "PossibleValueStringHandle[0]": "1(Disabled)",
        "PossibleValueStringHandle[1]": "2(Enabled)",
        "NumberOfDefaultValues": 1,
        "DefaultValueStringHandleIndex[0]": 1,
        "StringHandle": "2(Enabled)"
    }
]

./pldmtool bios GetBIOSTable -t 2
[
    {
        "AttributeHandle": 0,
        "AttributeType": "BIOSString",
        "CurrentStringLength": 0,
        "CurrentString": ""
    },
...
...
   {
        "AttributeHandle": 16,
        "AttributeType": "BIOSEnumeration",
        "NumberOfCurrentValues": 1,
        "CurrentValueStringHandleIndex[0]": "Enabled"
    }
]

./pldmtool bios GetBIOSAttributeCurrentValueByHandle -a pvm-pcie-error-inject
{
    "CurrentValue": "Enabled"
}

./pldmtool bios SetBIOSAttributeCurrentValue -a vmi-if0-ipv4-method -d IPv4Static
{
    "Response": "SUCCESS"
}

Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
Change-Id: If58e2ce380efcad228e4440316cd2653eada9e73
diff --git a/pldmtool/pldm_cmd_helper.hpp b/pldmtool/pldm_cmd_helper.hpp
index 3ce01f3..d71d0d3 100644
--- a/pldmtool/pldm_cmd_helper.hpp
+++ b/pldmtool/pldm_cmd_helper.hpp
@@ -13,6 +13,7 @@
 #include <unistd.h>
 
 #include <CLI/CLI.hpp>
+#include <nlohmann/json.hpp>
 
 #include <cstring>
 #include <iomanip>
@@ -28,6 +29,7 @@
 using namespace pldm::utils;
 constexpr uint8_t PLDM_ENTITY_ID = 8;
 constexpr uint8_t MCTP_MSG_TYPE_PLDM = 1;
+using ordered_json = nlohmann::ordered_json;
 
 /** @brief Print the buffer
  *
@@ -57,6 +59,18 @@
         std::cout << msg << s.str() << std::endl;
     }
 }
+
+/** @brief Display in JSON format.
+ *
+ *  @param[in]  data - data to print in json
+ *
+ *  @return - None
+ */
+static inline void DisplayInJson(const ordered_json& data)
+{
+    std::cout << data.dump(4) << std::endl;
+}
+
 /** @brief MCTP socket read/recieve
  *
  *  @param[in]  requestMsg - Request message to compare against loopback