diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -646,11 +646,13 @@ switch (m_type) { case Type::ELISION: { // If the inner result is empty, use three dots for elision - sections.PushSection({indent_next + "...", m_description}); + sections.PushSection( + {indent + "..." + maybe_separator, m_description}); return; } case Type::NONE: { - sections.PushSection({indent + "None", Description("json null")}); + sections.PushSection( + {indent + "null" + maybe_separator, Description("json null")}); return; } case Type::STR: { @@ -693,10 +695,10 @@ for (const auto &i : m_inner) { i.ToSections(sections, OuterType::ARR, current_indent + 2); } - if (m_type == Type::ARR) { + CHECK_NONFATAL(!m_inner.empty()); + if (m_type == Type::ARR && m_inner.back().m_type != Type::ELISION) { sections.PushSection({indent_next + "...", ""}); } else { - CHECK_NONFATAL(!m_inner.empty()); // Remove final comma, which would be invalid JSON sections.m_sections.back().m_left.pop_back(); } @@ -710,12 +712,13 @@ for (const auto &i : m_inner) { i.ToSections(sections, OuterType::OBJ, current_indent + 2); } - if (m_type == Type::OBJ_DYN) { + CHECK_NONFATAL(!m_inner.empty()); + if (m_type == Type::OBJ_DYN && + m_inner.back().m_type != Type::ELISION) { // If the dictionary keys are dynamic, use three dots for // continuation sections.PushSection({indent_next + "...", ""}); } else { - CHECK_NONFATAL(!m_inner.empty()); // Remove final comma, which would be invalid JSON sections.m_sections.back().m_left.pop_back(); }