Make propertyValueIncorrect typesafe

Similar to the previous patches, make propertyValueIncorrect accept a
nlohmann::json object as input.  This removes the need for the dump()
call, which oddly enough, in our one usage, was actually incorrect, and
could cause bmcweb to throw an exception in parsing in theory.

Tested: Only used in one error condition.  Code compiles.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ie35d61101c2db88b16d42d71e66bceef540e8429
diff --git a/redfish-core/include/error_messages.hpp b/redfish-core/include/error_messages.hpp
index a396603..c49ac33 100644
--- a/redfish-core/include/error_messages.hpp
+++ b/redfish-core/include/error_messages.hpp
@@ -490,10 +490,10 @@
  * @param[in] arg2 Parameter of message that will replace %2 in its body.
  *
  * @returns Message PropertyValueIncorrect formatted to JSON */
-nlohmann::json propertyValueIncorrect(std::string_view arg1,
+nlohmann::json propertyValueIncorrect(const nlohmann::json& arg1,
                                       std::string_view arg2);
 
-void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
+void propertyValueIncorrect(crow::Response& res, const nlohmann::json& arg1,
                             std::string_view arg2);
 
 /**
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index 23e65f7..e245a99 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -705,9 +705,8 @@
                 {
                     metricProperties.emplace_back(uri);
                 }
-                messages::propertyValueIncorrect(asyncResp->res,
-                                                 metricProperties.dump(),
-                                                 "MetricProperties");
+                messages::propertyValueIncorrect(
+                    asyncResp->res, metricProperties, "MetricProperties");
                 return;
             }
             if (ec)
diff --git a/redfish-core/src/error_messages.cpp b/redfish-core/src/error_messages.cpp
index 64b5abb..c397e1f 100644
--- a/redfish-core/src/error_messages.cpp
+++ b/redfish-core/src/error_messages.cpp
@@ -850,14 +850,16 @@
  * See header file for more information
  * @endinternal
  */
-nlohmann::json propertyValueIncorrect(std::string_view arg1,
+nlohmann::json propertyValueIncorrect(const nlohmann::json& arg1,
                                       std::string_view arg2)
 {
+    std::string arg1Str = arg1.dump(2, ' ', true,
+                                    nlohmann::json::error_handler_t::replace);
     return getLog(redfish::registries::base::Index::propertyValueIncorrect,
-                  std::to_array({arg1, arg2}));
+                  std::to_array<std::string_view>({arg1Str, arg2}));
 }
 
-void propertyValueIncorrect(crow::Response& res, std::string_view arg1,
+void propertyValueIncorrect(crow::Response& res, const nlohmann::json& arg1,
                             std::string_view arg2)
 {
     res.result(boost::beast::http::status::bad_request);