11 static std::string json_escape(
const std::string& inS)
14 outS.reserve(inS.size() * 2);
16 for (
unsigned int i = 0; i < inS.size(); i++) {
17 unsigned char ch = inS[i];
18 const char *escStr = escapes[ch];
30 unsigned int indentLevel)
const 35 unsigned int modIndent = indentLevel;
50 s +=
"\"" + json_escape(
val) +
"\"";
56 s += (
val ==
"1" ?
"true" :
"false");
63 static void indentStr(
unsigned int prettyIndent,
unsigned int indentLevel, std::string& s)
65 s.append(prettyIndent * indentLevel,
' ');
74 for (
unsigned int i = 0; i <
values.size(); i++) {
76 indentStr(prettyIndent, indentLevel, s);
77 s +=
values[i].write(prettyIndent, indentLevel + 1);
78 if (i != (
values.size() - 1)) {
86 indentStr(prettyIndent, indentLevel - 1, s);
96 for (
unsigned int i = 0; i <
keys.size(); i++) {
98 indentStr(prettyIndent, indentLevel, s);
99 s +=
"\"" + json_escape(
keys[i]) +
"\":";
102 s +=
values.at(i).write(prettyIndent, indentLevel + 1);
103 if (i != (
values.size() - 1))
110 indentStr(prettyIndent, indentLevel - 1, s);
std::vector< UniValue > values
std::string write(unsigned int prettyIndent=0, unsigned int indentLevel=0) const
void writeObject(unsigned int prettyIndent, unsigned int indentLevel, std::string &s) const
std::vector< std::string > keys
void writeArray(unsigned int prettyIndent, unsigned int indentLevel, std::string &s) const