mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 18:42:41 +01:00
add JSONFormatter
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "Poco/JSON/Stringifier.h"
|
||||
#include "Poco/JSON/Array.h"
|
||||
#include "Poco/JSON/Object.h"
|
||||
#include "Poco/JSONString.h"
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
@@ -69,24 +70,7 @@ void Stringifier::stringify(const Var& any, std::ostream& out, unsigned int inde
|
||||
|
||||
void Stringifier::formatString(const std::string& value, std::ostream& out)
|
||||
{
|
||||
out << '"';
|
||||
for (std::string::const_iterator it = value.begin(),
|
||||
end = value.end(); it != end; ++it)
|
||||
{
|
||||
switch (*it)
|
||||
{
|
||||
case '\\': out << "\\\\"; break;
|
||||
case '"': out << "\\\""; break;
|
||||
case '/': out << "\\/"; break;
|
||||
case '\b': out << "\\b"; break;
|
||||
case '\f': out << "\\f"; break;
|
||||
case '\n': out << "\\n"; break;
|
||||
case '\r': out << "\\r"; break;
|
||||
case '\t': out << "\\t"; break;
|
||||
default: out << *it; break;
|
||||
}
|
||||
}
|
||||
out << '"';
|
||||
Poco::toJSON(value, out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user