add JSONFormatter

This commit is contained in:
Alex Fabijanic
2015-02-10 00:21:53 -06:00
parent aaf32257e3
commit beb81b4f16
13 changed files with 445 additions and 154 deletions

View File

@@ -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);
}