Skip to content

Commit 21c10de

Browse files
committed
special threatment for null,true,false because they are non valid json
1 parent 6c7bee0 commit 21c10de

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/rpcclient.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <set>
1212
#include <stdint.h>
1313

14+
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
15+
1416
using namespace std;
1517
using namespace json_spirit;
1618

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

135137
// parse string as JSON, insert bool/number/object/etc. value
136138
else {
139+
//according to rfc4627 null, true, false are not valid json strings
137140
Value jVal;
138-
if (!jVal.read(strVal))
139-
throw runtime_error(string("Error parsing JSON:")+strVal);
141+
if(strVal == "null")
142+
jVal.setNull();
143+
else if(strVal == "true")
144+
jVal.setBool(true);
145+
else if(strVal == "false")
146+
jVal.setBool(false);
147+
else
148+
{
149+
if (!jVal.read(strVal))
150+
throw runtime_error(string("Error parsing JSON:")+strVal);
151+
}
140152
params.push_back(jVal);
141153
}
142154
}

0 commit comments

Comments
 (0)