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/rpc/client.cpp | |
parent | 1d02e599012721549d4c20b1b37fcc5ee7b961b6 (diff) |
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/rpc/client.cpp')
-rw-r--r-- | src/rpc/client.cpp | 10 |
1 files changed, 4 insertions, 6 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) |