Remove implicit conversions
Since 2020, nlohmann has recognized that implicit conversions to and
from json are an issue. Many bugs have been caused at both development
time and runtime due to unexpected implicit conversions from json to
std::string/int/bool. This commit disables implicit conversions using
JSON_USE_IMPLICIT_CONVERSIONS [1]. This option will become the default
in the future. That comment was written 3 years ago at this point, so
we should prepare.
Tested:
Redfish service validator passes.
[1] https://json.nlohmann.me/api/macros/json_use_implicit_conversions/
Change-Id: Id6cc47b9bbf8889e4777fd6d77ec992f3139962c
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/src/json_html_serializer.cpp b/src/json_html_serializer.cpp
index 1e1f7a7..b2d13bb 100644
--- a/src/json_html_serializer.cpp
+++ b/src/json_html_serializer.cpp
@@ -441,7 +441,12 @@
{
inATag = true;
out += "<a href=\"";
- dumpEscaped(out, i.value());
+ const std::string* str =
+ i.value().get_ptr<const std::string*>();
+ if (str != nullptr)
+ {
+ dumpEscaped(out, *str);
+ }
out += "\">";
}
dump(out, i.value());