Remove deprecated json decodes
These decodes haven't been standard practice for a while. While they
will likely break some downstream builds, we need to clean things up.
If you are seeing this commit message because your downstream build is
broken, please migrate your code to using nlohmann::json::object_t
instead of nlohmann::json when it does the unpack.
Tested: Code compiles.
Change-Id: Id892ee381b2d6b40a6366ee0622cde04d2cacd7b
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index 00e9dc7..28bcf07 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -501,15 +501,7 @@
std::optional<std::variant<double, std::nullptr_t>>*,
std::optional<std::variant<bool, std::nullptr_t>>*,
std::optional<std::vector<std::variant<nlohmann::json::object_t, std::nullptr_t>>>*,
- std::optional<std::vector<std::variant<std::string, nlohmann::json::object_t, std::nullptr_t>>>*,
-
- // Note, these types are kept for historical completeness, but should not be used,
- // As they do not provide object type safety. Instead, rely on nlohmann::json::object_t
- // Will be removed Q2 2025
- nlohmann::json*,
- std::optional<std::vector<nlohmann::json>>*,
- std::vector<nlohmann::json>*,
- std::optional<nlohmann::json>*
+ std::optional<std::vector<std::variant<std::string, nlohmann::json::object_t, std::nullptr_t>>>*
>;
// clang-format on
diff --git a/test/redfish-core/include/utils/json_utils_test.cpp b/test/redfish-core/include/utils/json_utils_test.cpp
index c778c13..c578be9 100644
--- a/test/redfish-core/include/utils/json_utils_test.cpp
+++ b/test/redfish-core/include/utils/json_utils_test.cpp
@@ -161,16 +161,19 @@
crow::Response res;
nlohmann::json jsonRequest = R"(
{
- "TestJson": [{"hello": "yes"}, [{"there": "no"}, "nice"]]
+ "TestJson": [{"hello": "yes"}, {"there": "no"}]
}
)"_json;
- std::vector<nlohmann::json> jsonVec;
+ std::vector<nlohmann::json::object_t> jsonVec;
ASSERT_TRUE(readJson(jsonRequest, res, "TestJson", jsonVec));
EXPECT_EQ(res.result(), boost::beast::http::status::ok);
EXPECT_THAT(res.jsonValue, IsEmpty());
- EXPECT_THAT(jsonVec, ElementsAre(R"({"hello": "yes"})"_json,
- R"([{"there": "no"}, "nice"])"_json));
+ nlohmann::json::object_t hello;
+ hello["hello"] = "yes";
+ nlohmann::json::object_t there;
+ there["there"] = "no";
+ EXPECT_THAT(jsonVec, ElementsAre(hello, there));
}
TEST(ReadJson, JsonSubElementValueAreUnpackedCorrectly)