summaryrefslogtreecommitdiffstats
path: root/base/debug/trace_event.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/debug/trace_event.cc')
-rw-r--r--base/debug/trace_event.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/base/debug/trace_event.cc b/base/debug/trace_event.cc
index 8eb774e..6529592 100644
--- a/base/debug/trace_event.cc
+++ b/base/debug/trace_event.cc
@@ -87,10 +87,13 @@ void TraceValue::AppendAsJSON(std::string* out) const {
*out += "\"";
start_pos = out->size();
*out += as_string() ? as_string() : "NULL";
- // replace " character with '
- while ((start_pos = out->find_first_of('\"', start_pos)) !=
- std::string::npos)
- (*out)[start_pos] = '\'';
+ // insert backslash before special characters for proper json format.
+ while ((start_pos = out->find_first_of("\\\"", start_pos)) !=
+ std::string::npos) {
+ out->insert(start_pos, 1, '\\');
+ // skip inserted escape character and following character.
+ start_pos += 2;
+ }
*out += "\"";
break;
default: