Skip to content

Commit

Permalink
rpc: allow empty JSON object result
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjors committed Dec 24, 2021
1 parent bfbf91d commit 8d1a3e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,10 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
return;
}
case Type::OBJ_DYN:
case Type::OBJ_EMPTY: {
sections.PushSection({indent + maybe_key + "{}", Description("empty JSON object")});
return;
}
case Type::OBJ: {
sections.PushSection({indent + maybe_key + "{", Description("json object")});
for (const auto& i : m_inner) {
Expand Down Expand Up @@ -879,6 +883,7 @@ bool RPCResult::MatchesType(const UniValue& result) const
return UniValue::VARR == result.getType();
}
case Type::OBJ_DYN:
case Type::OBJ_EMPTY:
case Type::OBJ: {
return UniValue::VOBJ == result.getType();
}
Expand Down
1 change: 1 addition & 0 deletions src/rpc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ struct RPCResult {
STR_AMOUNT, //!< Special string to represent a floating point amount
STR_HEX, //!< Special string with only hex chars
OBJ_DYN, //!< Special dictionary with keys that are not literals
OBJ_EMPTY, //!< Special type to allow empty OBJ
ARR_FIXED, //!< Special array that has a fixed number of entries
NUM_TIME, //!< Special numeric to denote unix epoch time
ELISION, //!< Special type to denote elision (...)
Expand Down

0 comments on commit 8d1a3e6

Please sign in to comment.