фикс косячных строк в json, фича: SNR в вебке

This commit is contained in:
2025-01-20 15:55:03 +03:00
parent bafef9c51c
commit 3a1699d865
4 changed files with 64 additions and 11 deletions

View File

@@ -668,7 +668,10 @@ std::string api_driver::buildEscapedString(const std::string& source) {
str.replace(start_pos, 1, "\\\"");
start_pos += 2;
}
return "\"" + str + "\"";
for (start_pos = 0; start_pos < str.size() && (str[start_pos] == ' ' || str[start_pos] == '\n' || str[start_pos] == '\t'); start_pos++) {}
size_t end_pos = str.size() - 1;
for (; end_pos > start_pos && end_pos != 0 && (str[end_pos] == ' ' || str[end_pos] == '\n' || str[end_pos] == '\t'); end_pos--) {}
return "\"" + str.substr(start_pos, end_pos - start_pos + 1) + "\"";
}
static void writeDouble(std::ostream& out, double value, int prec = 2) {