From 7727603e44f8f674e0fc8389e78047e2b56e6052 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Wed, 30 Nov 2022 16:27:13 +0000 Subject: [PATCH] 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. --- src/rpc/client.cpp | 10 ++++------ 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 &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