summaryrefslogtreecommitdiffstats
path: root/redfish-core/include/utils
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2019-08-28 14:02:04 -0700
committerEd Tanous <ed.tanous@intel.com>2019-09-04 20:36:07 +0000
commit8ebc91f6b7f6820f0b2a7b99401002cb4524cd79 (patch)
treeab7a7fb4b82e5449412d8983d10142b329d38b67 /redfish-core/include/utils
parentee344e0fa76b2b24866d25b305e12ae82824f01b (diff)
downloadbmcweb-8ebc91f6b7f6820f0b2a7b99401002cb4524cd79.tar.gz
bmcweb-8ebc91f6b7f6820f0b2a7b99401002cb4524cd79.zip
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
Diffstat (limited to 'redfish-core/include/utils')
-rw-r--r--redfish-core/include/utils/json_utils.hpp3
1 files changed, 2 insertions, 1 deletions
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 @@ bool unpackValue(nlohmann::json& jsonValue, const std::string& key,
{
// 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;
OpenPOWER on IntegriCloud