Merge e35e118656 into merged_master (Bitcoin PR #18508)

This commit is contained in:
Andrew Poelstra 2020-11-26 01:08:09 +00:00
commit 23ff87c258

View file

@ -617,11 +617,11 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
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: {
@ -654,10 +654,10 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
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();
}
@ -670,11 +670,11 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
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();
}