When I'm using Boost.JSON along with Boost.Beast, it's common to parse a json frame from a remote http/websocket server and do some processing with it.
A typical scenario is, I need to pass a json::string to a function where a std::string_view is expected.
I can use standalone Boost.JSON with macro BOOST_JSON_STANDALONE to replace boost::string_view with std::string_view. But since I also need Boost.Beast, mixing Boost and standalone Boost.JSON would result in a lot of "macro redefinition" error.
So now I have to tediously do the conversion like this everytime
void process_sv(std::string_view sv);
auto j_str = j_v.as_string();
auto j_sv = std::string_view(j_str.data(), j_str.size());
process_sv(j_sv);
It would make it much more convenient if a direct conversion from json::string to std::string_view is available.
Thank you!
When I'm using Boost.JSON along with Boost.Beast, it's common to parse a json frame from a remote http/websocket server and do some processing with it.
A typical scenario is, I need to pass a
json::stringto a function where astd::string_viewis expected.I can use standalone Boost.JSON with macro
BOOST_JSON_STANDALONEto replaceboost::string_viewwithstd::string_view. But since I also need Boost.Beast, mixing Boost and standalone Boost.JSON would result in a lot of "macro redefinition" error.So now I have to tediously do the conversion like this everytime
It would make it much more convenient if a direct conversion from
json::stringtostd::string_viewis available.Thank you!