0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-02 09:46:52 -05:00

rpc: allow empty JSON object result

This commit is contained in:
Sjors Provoost 2021-12-13 13:24:17 +07:00
parent bfbf91d0b2
commit 8d1a3e6498
No known key found for this signature in database
GPG key ID: 57FF9BDBCC301009
2 changed files with 6 additions and 0 deletions

View file

@ -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) {
@ -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();
}

View file

@ -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 (...)