Skip to content

Commit 444d40e

Browse files
committed
Quotes and backslashes will now be escaped with a slash.
1 parent 8012590 commit 444d40e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

stringify/jss_string.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ namespace JSON
55
std::ostream& stringify (std::ostream& stream, std::string const& name, std::string const& value, StringificationOptions const& options)
66
{
77
WRITE_NAME(stream);
8-
stream << '"'
9-
<< value
10-
<< '"'
11-
;
8+
stream << '"';
9+
for (auto const& i : value)
10+
{
11+
if (i == '"' || i == '\\')
12+
stream.put('\\');
13+
stream.put(i);
14+
}
15+
stream << '"';
1216
return stream;
1317
}
1418
}

0 commit comments

Comments
 (0)