Remove brace initialization of json objects

Brace initialization of json objects, while quite interesting from an
academic sense, are very difficult for people to grok, and lead to
inconsistencies.  This patchset aims to remove a majority of them in
lieu of operator[].  Interestingly, this saves about 1% of the binary
size of bmcweb.

This also has an added benefit that as a design pattern, we're never
constructing a new object, then moving it into place, we're always
adding to the existing object, which in the future _could_ make things
like OEM schemas or properties easier, as there's no case where we're
completely replacing the response object.

Tested:
Ran redfish service validator.  No new failures.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Iae409b0a40ddd3ae6112cb2d52c6f6ab388595fe
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index be59811..740e393 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -60,9 +60,10 @@
                 {
                     continue;
                 }
-                pcieDeviceList.push_back(
-                    {{"@odata.id",
-                      "/redfish/v1/Systems/system/PCIeDevices/" + devName}});
+                nlohmann::json::object_t pcieDevice;
+                pcieDevice["@odata.id"] =
+                    "/redfish/v1/Systems/system/PCIeDevices/" + devName;
+                pcieDeviceList.push_back(std::move(pcieDevice));
             }
             asyncResp->res.jsonValue[name + "@odata.count"] =
                 pcieDeviceList.size();
@@ -88,14 +89,16 @@
                 {
                     return;
                 }
-                asyncResp->res.jsonValue = {
-                    {"@odata.type",
-                     "#PCIeDeviceCollection.PCIeDeviceCollection"},
-                    {"@odata.id", "/redfish/v1/Systems/system/PCIeDevices"},
-                    {"Name", "PCIe Device Collection"},
-                    {"Description", "Collection of PCIe Devices"},
-                    {"Members", nlohmann::json::array()},
-                    {"Members@odata.count", 0}};
+
+                asyncResp->res.jsonValue["@odata.type"] =
+                    "#PCIeDeviceCollection.PCIeDeviceCollection";
+                asyncResp->res.jsonValue["@odata.id"] =
+                    "/redfish/v1/Systems/system/PCIeDevices";
+                asyncResp->res.jsonValue["Name"] = "PCIe Device Collection";
+                asyncResp->res.jsonValue["Description"] =
+                    "Collection of PCIe Devices";
+                asyncResp->res.jsonValue["Members"] = nlohmann::json::array();
+                asyncResp->res.jsonValue["Members@odata.count"] = 0;
                 getPCIeDeviceList(asyncResp, "Members");
             });
 }
@@ -174,16 +177,16 @@
                         return;
                     }
 
-                    asyncResp->res.jsonValue = {
-                        {"@odata.type", "#PCIeDevice.v1_4_0.PCIeDevice"},
-                        {"@odata.id",
-                         "/redfish/v1/Systems/system/PCIeDevices/" + device},
-                        {"Name", "PCIe Device"},
-                        {"Id", device}};
-                    asyncResp->res.jsonValue["PCIeFunctions"] = {
-                        {"@odata.id",
-                         "/redfish/v1/Systems/system/PCIeDevices/" + device +
-                             "/PCIeFunctions"}};
+                    asyncResp->res.jsonValue["@odata.type"] =
+                        "#PCIeDevice.v1_4_0.PCIeDevice";
+                    asyncResp->res.jsonValue["@odata.id"] =
+                        "/redfish/v1/Systems/system/PCIeDevices/" + device;
+                    asyncResp->res.jsonValue["Name"] = "PCIe Device";
+                    asyncResp->res.jsonValue["Id"] = device;
+
+                    asyncResp->res.jsonValue["PCIeFunctions"]["@odata.id"] =
+                        "/redfish/v1/Systems/system/PCIeDevices/" + device +
+                        "/PCIeFunctions";
                     for (const auto& property : pcieDevProperties)
                     {
                         const std::string* propertyString =
@@ -259,14 +262,15 @@
             {
                 return;
             }
-            asyncResp->res.jsonValue = {
-                {"@odata.type",
-                 "#PCIeFunctionCollection.PCIeFunctionCollection"},
-                {"@odata.id", "/redfish/v1/Systems/system/PCIeDevices/" +
-                                  device + "/PCIeFunctions"},
-                {"Name", "PCIe Function Collection"},
-                {"Description",
-                 "Collection of PCIe Functions for PCIe Device " + device}};
+
+            asyncResp->res.jsonValue["@odata.type"] =
+                "#PCIeFunctionCollection.PCIeFunctionCollection";
+            asyncResp->res.jsonValue["@odata.id"] =
+                "/redfish/v1/Systems/system/PCIeDevices/" + device +
+                "/PCIeFunctions";
+            asyncResp->res.jsonValue["Name"] = "PCIe Function Collection";
+            asyncResp->res.jsonValue["Description"] =
+                "Collection of PCIe Functions for PCIe Device " + device;
 
             auto getPCIeDeviceCallback =
                 [asyncResp, device](
@@ -315,11 +319,11 @@
                         {
                             return;
                         }
-                        pcieFunctionList.push_back(
-                            {{"@odata.id",
-                              "/redfish/v1/Systems/system/PCIeDevices/" +
-                                  device + "/PCIeFunctions/" +
-                                  std::to_string(functionNum)}});
+                        nlohmann::json::object_t pcieFunction;
+                        pcieFunction["@odata.id"] =
+                            "/redfish/v1/Systems/system/PCIeDevices/" + device +
+                            "/PCIeFunctions/" + std::to_string(functionNum);
+                        pcieFunctionList.push_back(std::move(pcieFunction));
                     }
                     asyncResp->res.jsonValue["Members@odata.count"] =
                         pcieFunctionList.size();
@@ -371,7 +375,8 @@
                         return;
                     }
 
-                    // Check if this function exists by looking for a device ID
+                    // Check if this function exists by looking for a device
+                    // ID
                     std::string functionName = "Function" + function;
                     std::string devIDProperty = functionName + "DeviceId";
 
@@ -392,19 +397,18 @@
                         return;
                     }
 
-                    asyncResp->res.jsonValue = {
-                        {"@odata.type", "#PCIeFunction.v1_2_0.PCIeFunction"},
-                        {"@odata.id",
-                         "/redfish/v1/Systems/system/PCIeDevices/" + device +
-                             "/PCIeFunctions/" + function},
-                        {"Name", "PCIe Function"},
-                        {"Id", function},
-                        {"FunctionId", std::stoi(function)},
-                        {"Links",
-                         {{"PCIeDevice",
-                           {{"@odata.id",
-                             "/redfish/v1/Systems/system/PCIeDevices/" +
-                                 device}}}}}};
+                    asyncResp->res.jsonValue["@odata.type"] =
+                        "#PCIeFunction.v1_2_0.PCIeFunction";
+                    asyncResp->res.jsonValue["@odata.id"] =
+                        "/redfish/v1/Systems/system/PCIeDevices/" + device +
+                        "/PCIeFunctions/" + function;
+                    asyncResp->res.jsonValue["Name"] = "PCIe Function";
+                    asyncResp->res.jsonValue["Id"] = function;
+                    asyncResp->res.jsonValue["FunctionId"] =
+                        std::stoi(function);
+                    asyncResp->res
+                        .jsonValue["Links"]["PCIeDevice"]["@odata.id"] =
+                        "/redfish/v1/Systems/system/PCIeDevices/" + device;
 
                     for (const auto& property : pcieDevProperties)
                     {