mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
added '/' to the characters escaped in JSON
This commit is contained in:
@@ -70,9 +70,13 @@ void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int inde
|
|||||||
void Stringifier::formatString(const std::string& value, std::ostream& out)
|
void Stringifier::formatString(const std::string& value, std::ostream& out)
|
||||||
{
|
{
|
||||||
out << '"';
|
out << '"';
|
||||||
for (std::string::const_iterator it = value.begin(); it != value.end(); ++it)
|
for (std::string::const_iterator it = value.begin(),
|
||||||
|
end = value.end(); it != end; ++it)
|
||||||
{
|
{
|
||||||
if (*it <= 0x1F || *it == '"' || *it == '\\') out << '\\';
|
if (*it <= 0x1F || *it == '"' || *it == '\\' || *it == '/')
|
||||||
|
{
|
||||||
|
out << '\\';
|
||||||
|
}
|
||||||
out << *it;
|
out << *it;
|
||||||
}
|
}
|
||||||
out << '"';
|
out << '"';
|
||||||
|
|||||||
@@ -1231,7 +1231,7 @@ void JSONTest::testStringify()
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
jObj.stringify(ss);
|
jObj.stringify(ss);
|
||||||
|
|
||||||
assert(ss.str() == "{\"bar/\":0,\"baz\":0,\"foo\\\\\":0,\"q\\\"uote\\\"d\":0}");
|
assert(ss.str() == "{\"bar\\/\":0,\"baz\":0,\"foo\\\\\":0,\"q\\\"uote\\\"d\":0}");
|
||||||
|
|
||||||
std::string json = "{ \"Simpsons\" : { \"husband\" : { \"name\" : \"Homer\" , \"age\" : 38 }, \"wife\" : { \"name\" : \"Marge\", \"age\" : 36 }, "
|
std::string json = "{ \"Simpsons\" : { \"husband\" : { \"name\" : \"Homer\" , \"age\" : 38 }, \"wife\" : { \"name\" : \"Marge\", \"age\" : 36 }, "
|
||||||
"\"children\" : [ \"Bart\", \"Lisa\", \"Maggie\" ], "
|
"\"children\" : [ \"Bart\", \"Lisa\", \"Maggie\" ], "
|
||||||
|
|||||||
Reference in New Issue
Block a user