Question on Json conversion in 4.6
Closed this issue · 1 comments
benjaminholdennearearth commented
In 4.5 I could register json conversion functions such as:
void jsonPoint(const geometry_msgs::msg::Point& p, nlohmann::json& j)
{
j["x"] = p.x;
j["y"] = p.y;
j["z"] = p.z;
}
void jsonTime(const rclcpp::Time& t, nlohmann::json& j)
{
j["stamp"] = t.seconds();
}
void jsonOptionalString(const std::optional<std::string>& s, nlohmann::json& j)
{
if (s.has_value())
{
j["value"] = *s;
}
else
{
j["value"] = "nullopt";
}
}
However in 4.6 with the removal of adding custom converters in favor of the macro BT_JSON_CONVERTER
I cannot figure out how to replicate this behavior and was wondering:
- Was this functionality removed? And was it removed on purpose?
- How I can recreate this in 4.6 if it was not removed?
I can only find examples of using the macro with simple structs. I have been reading through the code to try and figure this out, but have not made any progress yet so I figured I would reach out in case there is a simple solution.
Thank you for your time and for all the hard work on this!
facontidavide commented
Fixed