diff options
author | stickies-v <stickies-v@protonmail.com> | 2022-11-30 16:27:13 +0000 |
---|---|---|
committer | stickies-v <stickies-v@protonmail.com> | 2023-01-18 17:01:21 +0000 |
commit | 7727603e44f8f674e0fc8389e78047e2b56e6052 (patch) | |
tree | 5f7e4ff21bc70f0094daf2da53dada97e905016b /src | |
parent | 1d02e599012721549d4c20b1b37fcc5ee7b961b6 (diff) | |
download | bitcoin-7727603e44f8f674e0fc8389e78047e2b56e6052.tar.xz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/client.cpp | 10 | ||||
-rw-r--r-- | src/rpc/client.h | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 5fe914f0a1..a94c7e8c29 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -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) diff --git a/src/rpc/client.h b/src/rpc/client.h index b9fee5bbb3..644081ac22 100644 --- a/src/rpc/client.h +++ b/src/rpc/client.h @@ -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 |