summaryrefslogtreecommitdiff
path: root/src/tools/StringTools.cpp
diff options
context:
space:
mode:
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;
+}
+
}