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/sensors.hpp b/redfish-core/lib/sensors.hpp
index 3a5c73b..c7676db 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -1263,7 +1263,7 @@
                                 {
                                     health = "Critical";
                                 }
-                                std::vector<nlohmann::json> redfishCollection;
+                                nlohmann::json::array_t redfishCollection;
                                 const auto& fanRedfish =
                                     sensorsAsyncResp->asyncResp->res
                                         .jsonValue["Fans"];
@@ -1286,9 +1286,11 @@
                                         });
                                     if (schemaItem != fanRedfish.end())
                                     {
-                                        redfishCollection.push_back(
-                                            {{"@odata.id",
-                                              (*schemaItem)["@odata.id"]}});
+                                        nlohmann::json::object_t collection;
+                                        collection["@odata.id"] =
+                                            (*schemaItem)["@odata.id"];
+                                        redfishCollection.emplace_back(
+                                            std::move(collection));
                                     }
                                     else
                                     {
@@ -1307,23 +1309,25 @@
                                 nlohmann::json& jResp =
                                     sensorsAsyncResp->asyncResp->res
                                         .jsonValue["Redundancy"];
-                                jResp.push_back(
-                                    {{"@odata.id",
-                                      "/redfish/v1/Chassis/" +
-                                          sensorsAsyncResp->chassisId + "/" +
-                                          sensorsAsyncResp->chassisSubNode +
-                                          "#/Redundancy/" +
-                                          std::to_string(jResp.size())},
-                                     {"@odata.type",
-                                      "#Redundancy.v1_3_2.Redundancy"},
-                                     {"MinNumNeeded", minNumNeeded},
-                                     {"MemberId", name},
-                                     {"Mode", "N+m"},
-                                     {"Name", name},
-                                     {"RedundancySet", redfishCollection},
-                                     {"Status",
-                                      {{"Health", health},
-                                       {"State", "Enabled"}}}});
+
+                                nlohmann::json::object_t redundancy;
+                                redundancy["@odata.id"] =
+                                    "/redfish/v1/Chassis/" +
+                                    sensorsAsyncResp->chassisId + "/" +
+                                    sensorsAsyncResp->chassisSubNode +
+                                    "#/Redundancy/" +
+                                    std::to_string(jResp.size());
+                                redundancy["@odata.type"] =
+                                    "#Redundancy.v1_3_2.Redundancy";
+                                redundancy["MinNumNeeded"] = minNumNeeded;
+                                redundancy["MemberId"] = name;
+                                redundancy["Mode"] = "N+m";
+                                redundancy["Name"] = name;
+                                redundancy["RedundancySet"] = redfishCollection;
+                                redundancy["Status"]["Health"] = health;
+                                redundancy["Status"]["State"] = "Enabled";
+
+                                jResp.push_back(std::move(redundancy));
                             },
                             owner, path, "org.freedesktop.DBus.Properties",
                             "GetAll",
@@ -2616,12 +2620,13 @@
                             // Put multiple "sensors" into a single
                             // PowerControl. Follows MemberId naming and
                             // naming in power.hpp.
-                            tempArray.push_back(
-                                {{"@odata.id",
-                                  "/redfish/v1/Chassis/" +
-                                      sensorsAsyncResp->chassisId + "/" +
-                                      sensorsAsyncResp->chassisSubNode + "#/" +
-                                      fieldName + "/0"}});
+                            nlohmann::json::object_t power;
+                            power["@odata.id"] =
+                                "/redfish/v1/Chassis/" +
+                                sensorsAsyncResp->chassisId + "/" +
+                                sensorsAsyncResp->chassisSubNode + "#/" +
+                                fieldName + "/0";
+                            tempArray.push_back(std::move(power));
                         }
                         sensorJson = &(tempArray.back());
                     }
@@ -2636,22 +2641,23 @@
                     }
                     else if (fieldName == "Members")
                     {
-                        tempArray.push_back(
-                            {{"@odata.id",
-                              "/redfish/v1/Chassis/" +
-                                  sensorsAsyncResp->chassisId + "/" +
-                                  sensorsAsyncResp->chassisSubNode + "/" +
-                                  sensorName}});
+                        nlohmann::json::object_t member;
+                        member["@odata.id"] =
+                            "/redfish/v1/Chassis/" +
+                            sensorsAsyncResp->chassisId + "/" +
+                            sensorsAsyncResp->chassisSubNode + "/" + sensorName;
+                        tempArray.push_back(std::move(member));
                         sensorJson = &(tempArray.back());
                     }
                     else
                     {
-                        tempArray.push_back(
-                            {{"@odata.id",
-                              "/redfish/v1/Chassis/" +
-                                  sensorsAsyncResp->chassisId + "/" +
-                                  sensorsAsyncResp->chassisSubNode + "#/" +
-                                  fieldName + "/"}});
+                        nlohmann::json::object_t member;
+                        member["@odata.id"] = "/redfish/v1/Chassis/" +
+                                              sensorsAsyncResp->chassisId +
+                                              "/" +
+                                              sensorsAsyncResp->chassisSubNode +
+                                              "#/" + fieldName + "/";
+                        tempArray.push_back(std::move(member));
                         sensorJson = &(tempArray.back());
                     }
                 }
@@ -3004,9 +3010,11 @@
             messages::internalError(asyncResp->asyncResp->res);
             return;
         }
-        entriesArray.push_back(
-            {{"@odata.id", "/redfish/v1/Chassis/" + asyncResp->chassisId + "/" +
-                               asyncResp->chassisSubNode + "/" + sensorName}});
+        nlohmann::json::object_t member;
+        member["@odata.id"] = "/redfish/v1/Chassis/" + asyncResp->chassisId +
+                              "/" + asyncResp->chassisSubNode + "/" +
+                              sensorName;
+        entriesArray.push_back(std::move(member));
     }
 
     asyncResp->asyncResp->res.jsonValue["Members@odata.count"] =