summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
Diffstat (limited to 'base')
-rw-r--r--base/json/string_escape.cc12
-rw-r--r--base/json/string_escape.h7
2 files changed, 18 insertions, 1 deletions
diff --git a/base/json/string_escape.cc b/base/json/string_escape.cc
index 4e1418c..5bf0b86 100644
--- a/base/json/string_escape.cc
+++ b/base/json/string_escape.cc
@@ -82,10 +82,22 @@ void JsonDoubleQuote(const std::string& str,
JsonDoubleQuoteT(str, put_in_quotes, dst);
}
+std::string GetDoubleQuotedJson(const std::string& str) {
+ std::string dst;
+ JsonDoubleQuote(str, true, &dst);
+ return dst;
+}
+
void JsonDoubleQuote(const string16& str,
bool put_in_quotes,
std::string* dst) {
JsonDoubleQuoteT(str, put_in_quotes, dst);
}
+std::string GetDoubleQuotedJson(const string16& str) {
+ std::string dst;
+ JsonDoubleQuote(str, true, &dst);
+ return dst;
+}
+
} // namespace base
diff --git a/base/json/string_escape.h b/base/json/string_escape.h
index 7d74021..7c64c29 100644
--- a/base/json/string_escape.h
+++ b/base/json/string_escape.h
@@ -13,7 +13,7 @@
namespace base {
-// Escape |str| appropriately for a JSON string litereal, _appending_ the
+// Escape |str| appropriately for a JSON string literal, _appending_ the
// result to |dst|. This will create unicode escape sequences (\uXXXX).
// If |put_in_quotes| is true, the result will be surrounded in double quotes.
// The outputted literal, when interpreted by the browser, should result in a
@@ -22,10 +22,15 @@ void JsonDoubleQuote(const std::string& str,
bool put_in_quotes,
std::string* dst);
+// Same as above, but always returns the result double quoted.
+std::string GetDoubleQuotedJson(const std::string& str);
+
void JsonDoubleQuote(const string16& str,
bool put_in_quotes,
std::string* dst);
+// Same as above, but always returns the result double quoted.
+std::string GetDoubleQuotedJson(const string16& str);
} // namespace base