bmcweb: Enable redfish unpacking of complex types

In certain cases, redfish wants to unpack specialized types that might
be more complex than just simple structs.  This commit adds the ability
to unpack a nlohman json object directly, and moves the ethernet schema
over to the new api

Change-Id: Ib3c25e6c4d8f0a163647092adfb454355d329170
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index f3c3ec3..e31561e 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -932,31 +932,18 @@
     void doPatch(crow::Response& res, const crow::Request& req,
                  const std::vector<std::string>& params) override
     {
-        nlohmann::json patch;
-        if (!json_util::processJsonFromRequest(res, req, patch))
+        std::optional<nlohmann::json> oem;
+
+        if (!json_util::readJson(req, res, "Oem", oem))
         {
             return;
         }
+
         std::shared_ptr<AsyncResp> response = std::make_shared<AsyncResp>(res);
-        for (const auto& topLevel : patch.items())
+
+        if (oem)
         {
-            if (topLevel.key() == "Oem")
-            {
-                if (!topLevel.value().is_object())
-                {
-                    BMCWEB_LOG_ERROR << "Bad Patch " << topLevel.key();
-                    messages::propertyValueFormatError(
-                        response->res, topLevel.key(), "OemManager.Oem");
-                    return;
-                }
-            }
-            else
-            {
-                BMCWEB_LOG_ERROR << "Bad Patch " << topLevel.key();
-                messages::propertyUnknown(response->res, topLevel.key());
-                return;
-            }
-            for (const auto& oemLevel : topLevel.value().items())
+            for (const auto& oemLevel : oem->items())
             {
                 if (oemLevel.key() == "OpenBmc")
                 {
@@ -964,8 +951,7 @@
                     {
                         BMCWEB_LOG_ERROR << "Bad Patch " << oemLevel.key();
                         messages::propertyValueFormatError(
-                            response->res, topLevel.key(),
-                            "OemManager.OpenBmc");
+                            response->res, "Oem", "OemManager.OpenBmc");
                         return;
                     }
                     for (const auto& typeLevel : oemLevel.value().items())