diff options
author | Jeff Garzik <jgarzik@bitpay.com> | 2014-08-20 00:14:53 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@bitpay.com> | 2014-08-20 00:27:49 -0400 |
commit | dee9324a0bdbf92a0764213f9b24424a7600f47b (patch) | |
tree | e6cb922b4b4a0de2848b4b6e8ac7fe3c2f1c922c /src/univalue | |
parent | 42642c96950f50bec0866483876a6eef27318fec (diff) |
UniValue: compact (!pretty) output should not include extra whitespace
Diffstat (limited to 'src/univalue')
-rw-r--r-- | src/univalue/univalue_write.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/univalue/univalue_write.cpp b/src/univalue/univalue_write.cpp index 70762a1ef1..042091a827 100644 --- a/src/univalue/univalue_write.cpp +++ b/src/univalue/univalue_write.cpp @@ -91,8 +91,11 @@ void UniValue::writeArray(unsigned int prettyIndent, unsigned int indentLevel, s if (prettyIndent) s += indentStr(prettyIndent, indentLevel); s += values[i].write(prettyIndent, indentLevel + 1); - if (i != (values.size() - 1)) - s += ", "; + if (i != (values.size() - 1)) { + s += ","; + if (prettyIndent) + s += " "; + } if (prettyIndent) s += "\n"; } @@ -111,7 +114,9 @@ void UniValue::writeObject(unsigned int prettyIndent, unsigned int indentLevel, for (unsigned int i = 0; i < keys.size(); i++) { if (prettyIndent) s += indentStr(prettyIndent, indentLevel); - s += "\"" + json_escape(keys[i]) + "\": "; + s += "\"" + json_escape(keys[i]) + "\":"; + if (prettyIndent) + s += " "; s += values[i].write(prettyIndent, indentLevel + 1); if (i != (values.size() - 1)) s += ","; |