Fix readJson to allow null as a complex type
Given that very few people have actually needed to unpack a null value
with readJson, it's not surprising that there are bugs there.
the simplest case that failed was attempting to unpack an array which
might contain null values, which should be allowed to be unpacked with a
nlohmann::json object, to allow error handling and the new delete cases,
but were rejected.
Tested:
Reran the unit test here, which succeeded.
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/23954/2
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: I50ae26645ad16f6a6228c27e6d501c08de4c622b
diff --git a/redfish-core/include/utils/json_utils.hpp b/redfish-core/include/utils/json_utils.hpp
index 3ef70dc..c36ad3c 100644
--- a/redfish-core/include/utils/json_utils.hpp
+++ b/redfish-core/include/utils/json_utils.hpp
@@ -168,7 +168,8 @@
{
// Must be a complex type. Simple types (int string etc) should be
// unpacked directly
- if (!jsonValue.is_object() && !jsonValue.is_array())
+ if (!jsonValue.is_object() && !jsonValue.is_array() &&
+ !jsonValue.is_null())
{
messages::propertyValueTypeError(res, jsonValue.dump(), key);
return false;