@@ -293,7 +293,7 @@ UniValue JSONRPCTransactionError(TransactionError terr, const std::string& err_s
293
293
struct Section {
294
294
Section (const std::string& left, const std::string& right)
295
295
: m_left{left}, m_right{right} {}
296
- const std::string m_left;
296
+ std::string m_left;
297
297
const std::string m_right;
298
298
};
299
299
@@ -645,6 +645,10 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
645
645
}
646
646
if (m_type == Type::ARR) {
647
647
sections.PushSection ({indent_next + " ..." , " " });
648
+ } else {
649
+ CHECK_NONFATAL (!m_inner.empty ());
650
+ // Remove final comma, which would be invalid JSON
651
+ sections.m_sections .back ().m_left .pop_back ();
648
652
}
649
653
sections.PushSection ({indent + " ]" + maybe_separator, " " });
650
654
return ;
@@ -658,6 +662,10 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
658
662
if (m_type == Type::OBJ_DYN) {
659
663
// If the dictionary keys are dynamic, use three dots for continuation
660
664
sections.PushSection ({indent_next + " ..." , " " });
665
+ } else {
666
+ CHECK_NONFATAL (!m_inner.empty ());
667
+ // Remove final comma, which would be invalid JSON
668
+ sections.m_sections .back ().m_left .pop_back ();
661
669
}
662
670
sections.PushSection ({indent + " }" + maybe_separator, " " });
663
671
return ;
0 commit comments