write_json is converting the string "test/123"
as "test\/123"
. How to remove the special character (\
) that write_json is adding to the string in boost C++
Thanks,
It's being escaped. It's valid JSON, so any JSON parser should be able to read it correctly.
Put bluntly, yours is not a problem. If you think it is, you're doing something wrong.
Other than that, please don't use Boost Property Tree as if it were a JSON library. It is not.
Boost 1.75 introduced Boost Json, which is.
#include <boost/json.hpp>
#include <boost/json/src.hpp>
#include <iostream>
namespace json = boost::json;
int main() {
{
json::value s = "test/123";
std::cout << json::serialize(s) << std::endl;
}
{
auto s = json::parse(R"("test\/123")");
std::cout << json::serialize(s) << std::endl;
}
}
Prints
"test/123"
"test/123"