Skip to content

Commit

Permalink
special threatment for null,true,false because they are non valid json
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Jun 4, 2015
1 parent 6c7bee0 commit 21c10de
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/rpcclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <set>
#include <stdint.h>

#include <boost/algorithm/string/case_conv.hpp> // for to_lower()

using namespace std;
using namespace json_spirit;

Expand Down Expand Up @@ -134,9 +136,19 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector<std::stri

// parse string as JSON, insert bool/number/object/etc. value
else {
//according to rfc4627 null, true, false are not valid json strings
Value jVal;
if (!jVal.read(strVal))
throw runtime_error(string("Error parsing JSON:")+strVal);
if(strVal == "null")
jVal.setNull();
else if(strVal == "true")
jVal.setBool(true);
else if(strVal == "false")
jVal.setBool(false);
else
{
if (!jVal.read(strVal))
throw runtime_error(string("Error parsing JSON:")+strVal);
}
params.push_back(jVal);
}
}
Expand Down

0 comments on commit 21c10de

Please sign in to comment.