mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-24 16:01:26 +02:00
refactor: reduce unnecessary complexity in ParseNonRFCJSONValue
Since https://github.com/jgarzik/univalue/pull/31, UniValue::read() can now parse raw literals directly, so there is no more need to wrap them into an array first.
This commit is contained in:
parent
1d02e59901
commit
7727603e44
@ -253,13 +253,11 @@ static CRPCConvertTable rpcCvtTable;
|
||||
/** Non-RFC4627 JSON parser, accepts internal values (such as numbers, true, false, null)
|
||||
* as well as objects and arrays.
|
||||
*/
|
||||
UniValue ParseNonRFCJSONValue(const std::string& strVal)
|
||||
UniValue ParseNonRFCJSONValue(const std::string& raw)
|
||||
{
|
||||
UniValue jVal;
|
||||
if (!jVal.read(std::string("[")+strVal+std::string("]")) ||
|
||||
!jVal.isArray() || jVal.size()!=1)
|
||||
throw std::runtime_error(std::string("Error parsing JSON: ") + strVal);
|
||||
return jVal[0];
|
||||
UniValue parsed;
|
||||
if (!parsed.read(raw)) throw std::runtime_error(std::string("Error parsing JSON: ") + raw);
|
||||
return parsed;
|
||||
}
|
||||
|
||||
UniValue RPCConvertValues(const std::string &strMethod, const std::vector<std::string> &strParams)
|
||||
|
@ -17,6 +17,6 @@ UniValue RPCConvertNamedValues(const std::string& strMethod, const std::vector<s
|
||||
/** Non-RFC4627 JSON parser, accepts internal values (such as numbers, true, false, null)
|
||||
* as well as objects and arrays.
|
||||
*/
|
||||
UniValue ParseNonRFCJSONValue(const std::string& strVal);
|
||||
UniValue ParseNonRFCJSONValue(const std::string& raw);
|
||||
|
||||
#endif // BITCOIN_RPC_CLIENT_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user