json
json copied to clipboard
json::string convert to std::string
Might be nice to have string::to_std_string
although this means including <string>
.
-
core/detail/string_view.hpp
includes<string>
so, not including it in JSON is moot. -
std::string s = json::string_view(json::string());
works. And with C++17auto s = std::string(json::string());
also works. Is this good enough?
Given
json::string js;
My intuition tells me that users want the expression js.to_string()
(alternatively: js.to_std_string()
) to return a std::string
. This clearly expresses intent and can be searched. But I could be convinced otherwise. What is typical practice here?
QString has toStdString, but I don't think Qt is the best example of model C++ API. I'm personally perfectly Ok with a conversion (even though it's a bit obscure in C++11 mode). So, let's keep the issue for now and see if users actually ask for a dedicated conversion function.
I would prefer if users simply worked with the native json::string
since that is the most efficient. Making it easy to convert to std::string
only encourages inefficiency.
Still no issues about this. I'm inclined to close this.