Remove JSON Spirit wrapper, remove JSON Spirit leftovers

- implement find_value() function for UniValue
- replace all Array/Value/Object types with UniValues, remove JSON Spirit to UniValue wrapper
- remove JSON Spirit sources
This commit is contained in:
Jonas Schnelli
2015-05-18 14:02:18 +02:00
committed by Jack Grigg
parent 851f58f94e
commit d014114d67
37 changed files with 212 additions and 2209 deletions

View File

@@ -12,8 +12,9 @@
#include <boost/filesystem/operations.hpp>
#include "univalue/univalue.h"
using namespace std;
using namespace json_spirit;
std::string HelpMessageCli()
{
@@ -96,7 +97,7 @@ static bool AppInitRPC(int argc, char* argv[])
return true;
}
UniValue CallRPC(const string& strMethod, const Array& params)
UniValue CallRPC(const string& strMethod, const UniValue& params)
{
// Connect to localhost
bool fUseSSL = GetBoolArg("-rpcssl", false);
@@ -155,7 +156,7 @@ UniValue CallRPC(const string& strMethod, const Array& params)
UniValue valReply(UniValue::VSTR);
if (!valReply.read(strReply))
throw runtime_error("couldn't parse reply from server");
const Object& reply = valReply.get_obj();
const UniValue& reply = valReply.get_obj();
if (reply.empty())
throw runtime_error("expected reply to have result, error and id properties");
@@ -189,13 +190,15 @@ int CommandLineRPC(int argc, char *argv[])
const UniValue reply = CallRPC(strMethod, params);
// Parse reply
const Value& result = find_value(reply, "result");
const Value& error = find_value(reply, "error");
const UniValue& result = find_value(reply, "result");
const UniValue& error = find_value(reply, "error");
if (!error.isNull()) {
// Error
strPrint = "error: " + error.write();
int code = error["code"].get_int();
if (fWait && code == RPC_IN_WARMUP)
throw CConnectionFailed("server in warmup");
strPrint = "error: " + error.write();
nRet = abs(code);
} else {
// Result