summaryrefslogtreecommitdiff
path: root/redfish-core/src/utils
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2018-09-21 23:38:49 +0300
committerEd Tanous <ed.tanous@intel.com>2018-10-22 19:04:10 +0300
commit9712f8ac42746e65f32c2bc3de0835846652568e (patch)
tree779224bc1c29105e0228626ea7335b610e266ddc /redfish-core/src/utils
parent820ce598b31a6f9bf4d3715d337b8e5ee47196c7 (diff)
downloadbmcweb-9712f8ac42746e65f32c2bc3de0835846652568e.tar.xz
Implement a new way of unpacking json to structs
The existing way of decoding json structures, while fast has some disadvantages. 1. it's very verbose to write. 2. It requires in depth knowlege of redfish error messages to get correct. 3. It _can_ lead to undesired behavior, like half of a patch being applied, if only some of the values have bad types. This commit implements a new interface for decoding redfish json named.... readJson. It is a templated function, that lets you decode json values based on type easily, while still handling all the correct error codes that were handled previously. Use is done similar to the example below: std::string required; boost::optional<std::string> optional; if (!json_util::readJson(req, res, "OptionalParam", optional, "RequiredParam", required)) { return; } if (optional){ // optional param was given, take action. } As part of this patchset, the systems schema is moved to the new interface, which deletes some of the code involved and shows the improvement in clarity. Change-Id: I041a97c84d294df8cd4de4c2702e5ee22c0bc120 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'redfish-core/src/utils')
-rw-r--r--redfish-core/src/utils/json_utils.cpp3
1 files changed, 0 insertions, 3 deletions
diff --git a/redfish-core/src/utils/json_utils.cpp b/redfish-core/src/utils/json_utils.cpp
index 868601f72d..e14131713a 100644
--- a/redfish-core/src/utils/json_utils.cpp
+++ b/redfish-core/src/utils/json_utils.cpp
@@ -15,8 +15,6 @@
*/
#include "utils/json_utils.hpp"
-#include <error_messages.hpp>
-
namespace redfish
{
@@ -521,5 +519,4 @@ bool processJsonFromRequest(crow::Response& res, const crow::Request& req,
}
} // namespace json_util
-
} // namespace redfish