Remove is_object
is_object doesn't throw, but generally is_object is used in some kind of
pattern of.
if (x.is_object()){
x["thing"];
}
operator[] technically throws if it's the wrong type, which bloats
binary sizes.
Replace these with the equivalent get_ptr<object_t>
Change-Id: If3734d7920f0a6f81efa10b3a2d91595e9e0af5a
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/include/sub_request.hpp b/redfish-core/include/sub_request.hpp
index df8cf70..c44644a 100644
--- a/redfish-core/include/sub_request.hpp
+++ b/redfish-core/include/sub_request.hpp
@@ -31,7 +31,7 @@
}
auto oemIt = reqJson.find("Oem");
- if (oemIt != reqJson.end() && oemIt->is_object())
+ if (oemIt != reqJson.end())
{
const nlohmann::json::object_t* oemObj =
oemIt->get_ptr<const nlohmann::json::object_t*>();
diff --git a/redfish-core/include/utils/query_param.hpp b/redfish-core/include/utils/query_param.hpp
index ca2822d..57b5d06 100644
--- a/redfish-core/include/utils/query_param.hpp
+++ b/redfish-core/include/utils/query_param.hpp
@@ -771,12 +771,14 @@
{
BMCWEB_LOG_DEBUG("placeResult for {}", locationToPlace);
propogateError(finalRes->res, res);
- if (!res.jsonValue.is_object() || res.jsonValue.empty())
+ nlohmann::json::object_t* obj =
+ res.jsonValue.get_ptr<nlohmann::json::object_t*>();
+ if (obj == nullptr || res.jsonValue.empty())
{
return;
}
nlohmann::json& finalObj = finalRes->res.jsonValue[locationToPlace];
- finalObj = std::move(res.jsonValue);
+ finalObj = std::move(*obj);
}
// Handles the very first level of Expand, and starts a chain of sub-queries