control: reduce json pointer usage
Adjust the JSON conversion code to avoid using pointers and instead use
the explicit conversion functions. There are cases where internally
the JSON object might store a number as a uint pointer and refuse to
give back the pointer value. Using the explicit conversions, when the
underlying type can be safely converted, is less error prone.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I16903820c472d63d6c18e9c73e0f60885a001731
diff --git a/control/json/config_base.hpp b/control/json/config_base.hpp
index c521c9f..7417403 100644
--- a/control/json/config_base.hpp
+++ b/control/json/config_base.hpp
@@ -117,21 +117,21 @@
*/
static const PropertyVariantType getJsonValue(const json& object)
{
- if (auto boolPtr = object.get_ptr<const bool*>())
+ if (object.is_boolean())
{
- return *boolPtr;
+ return object.get<bool>();
}
- if (auto intPtr = object.get_ptr<const int64_t*>())
+ if (object.is_number_integer())
{
- return *intPtr;
+ return object.get<int64_t>();
}
- if (auto doublePtr = object.get_ptr<const double*>())
+ if (object.is_number_float())
{
- return *doublePtr;
+ return object.get<double>();
}
- if (auto stringPtr = object.get_ptr<const std::string*>())
+ if (object.is_string())
{
- return *stringPtr;
+ return object.get<std::string>();
}
lg2::error(