13 static string json_escape(
const string& inS)
16 outS.reserve(inS.size() * 2);
18 for (
unsigned int i = 0; i < inS.size(); i++) {
19 unsigned char ch = inS[i];
20 const char *escStr = escapes[
ch];
32 unsigned int indentLevel)
const 37 unsigned int modIndent = indentLevel;
46 writeObject(prettyIndent, modIndent, s);
49 writeArray(prettyIndent, modIndent, s);
52 s +=
"\"" + json_escape(val) +
"\"";
58 s += (val ==
"1" ?
"true" :
"false");
65 static void indentStr(
unsigned int prettyIndent,
unsigned int indentLevel,
string& s)
67 s.append(prettyIndent * indentLevel,
' ');
76 for (
unsigned int i = 0; i < values.size(); i++) {
78 indentStr(prettyIndent, indentLevel, s);
79 s += values[i].write(prettyIndent, indentLevel + 1);
80 if (i != (values.size() - 1)) {
88 indentStr(prettyIndent, indentLevel - 1, s);
98 for (
unsigned int i = 0; i < keys.size(); i++) {
100 indentStr(prettyIndent, indentLevel, s);
101 s +=
"\"" + json_escape(keys[i]) +
"\":";
104 s += values.at(i).write(prettyIndent, indentLevel + 1);
105 if (i != (values.size() - 1))
112 indentStr(prettyIndent, indentLevel - 1, s);
void writeArray(unsigned int prettyIndent, unsigned int indentLevel, std::string &s) const
std::hash for asio::adress
void writeObject(unsigned int prettyIndent, unsigned int indentLevel, std::string &s) const
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
uint32_t ch(uint32_t x, uint32_t y, uint32_t z)