Remove nlohmann brace initialization
There's a few last places (outside of tests) where we still use
nlohmann brace initialization. Per the transforms we've been doing,
move these to constructing the objects explicitly, using operator[],
nlohmann::object_t and nlohmann::array_t. Theses were found by manual
inspection grepping for all uses of nlohmann::json.
This is done to reduce binary size and reduce the number of intermediate
objects being constructed. This commit saves a trivial amount of size
(~4KB, Half a percent of total) and in addition but makes our
construction consistent.
Tested:
Redfish service validator passes.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I7478479a9fdc41b254eef325002d413c1fb411a0
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 9fb125d..3530d79 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -1660,9 +1660,9 @@
jsonResponse["FQDN"] = fqdn;
}
- jsonResponse["VLANs"] = {
- {"@odata.id",
- "/redfish/v1/Managers/bmc/EthernetInterfaces/" + ifaceId + "/VLANs"}};
+ jsonResponse["VLANs"]["@odata.id"] =
+ crow::utility::urlFromPieces("redfish", "v1", "Managers", "bmc",
+ "EthernetInterfaces", ifaceId, "VLANs");
jsonResponse["NameServers"] = ethData.nameServers;
jsonResponse["StaticNameServers"] = ethData.staticNameServers;
@@ -1673,7 +1673,6 @@
ipv4StaticArray = nlohmann::json::array();
for (const auto& ipv4Config : ipv4Data)
{
-
std::string gatewayStr = ipv4Config.gateway;
if (gatewayStr.empty())
{