summaryrefslogtreecommitdiff
path: root/src/tools/StringTools.cpp
diff options
context:
space:
mode:
authorOleg Morozenkov <o.morozenkov@corp.mail.ru>2022-11-01 19:43:42 +0300
committerOleg Morozenkov <o.morozenkov@corp.mail.ru>2022-11-01 19:43:42 +0300
commite96d3a3d4f023dc0d5d4e60fb8efb5a40ce7a71d (patch)
treef57f44b1448204120229bd83f3654b32e3df79ed /src/tools/StringTools.cpp
parent30136601c6755e5d7c2174ebd4ed49595e10a54b (diff)
parent7abb2509b87ef1344da97ae734211715f291cfa2 (diff)
Merge remote-tracking branch 'llnulldisk/master' into merge-228
Diffstat (limited to 'src/tools/StringTools.cpp')
-rw-r--r--src/tools/StringTools.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/StringTools.cpp b/src/tools/StringTools.cpp
index 653047c..3e5e6c4 100644
--- a/src/tools/StringTools.cpp
+++ b/src/tools/StringTools.cpp
@@ -101,4 +101,22 @@ string urlDecode(const string& value) {
return result;
}
+std::string escapeJsonString(const std::string& value) {
+ string result;
+
+ for (const char& c : value) {
+ switch (c) {
+ case '"':
+ case '\\':
+ case '/':
+ result += '\\';
+ break;
+ }
+
+ result += c;
+ }
+
+ return result;
+}
+
}