web::json::value::string method has only one parameter - actual string to wrap:
```
static _ASYNCRTIMP value __cdecl string(utility::string_t value);
```
Internally, it creates an instance of _String class using single-parameter constructor:
```
_String(utility::string_t value) : m_string(std::move(value))
{
m_has_escape_char = has_escape_chars(*this);
}
```
__has_escape_chars__ method uses find_first_of algorithm, which has linear complexity (times number of characters to look for):
```
bool web::json::details::_String::has_escape_chars(const _String &str)
{
static const auto escapes = U("\"\\\b\f\r\n\t");
return str.m_string.find_first_of(escapes) != utility::string_t::npos;
}
```
For large strings (we encode images as base64 and pass them to the client as JSON) such check has huge performance penalty.
I suggest to add overload of web::json::value::string that allows to specify whether check for escape characters or not:
```
static _ASYNCRTIMP value __cdecl string(utility::string_t value, bool escaped_chars);
```
Comments: Thanks Steve, I've just submitted pull request with new overload implementation :)
```
static _ASYNCRTIMP value __cdecl string(utility::string_t value);
```
Internally, it creates an instance of _String class using single-parameter constructor:
```
_String(utility::string_t value) : m_string(std::move(value))
{
m_has_escape_char = has_escape_chars(*this);
}
```
__has_escape_chars__ method uses find_first_of algorithm, which has linear complexity (times number of characters to look for):
```
bool web::json::details::_String::has_escape_chars(const _String &str)
{
static const auto escapes = U("\"\\\b\f\r\n\t");
return str.m_string.find_first_of(escapes) != utility::string_t::npos;
}
```
For large strings (we encode images as base64 and pass them to the client as JSON) such check has huge performance penalty.
I suggest to add overload of web::json::value::string that allows to specify whether check for escape characters or not:
```
static _ASYNCRTIMP value __cdecl string(utility::string_t value, bool escaped_chars);
```
Comments: Thanks Steve, I've just submitted pull request with new overload implementation :)