6
7
8
9
10
11
12
13
14
15
16
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
40 r.params = nlohmann::json(nlohmann::json::value_t::discarded);
41 r.id = nlohmann::json(nlohmann::json::value_t::discarded);
43 j.at(
"jsonrpc").get_to(r.jsonrpc);
44 j.at(
"method").get_to(r.method);
46 if (j.contains(
"params")) {
47 r.params = j[
"params"];
50 if (j.contains(
"id")) {
54 if (r.params.is_discarded()) {
55 r.params = nlohmann::json::array();
57 else if (r.params.is_object()) {
58 r.params = nlohmann::json::array({r.params});
68 catch (
const nlohmann::json::exception&) {
72 if (req.jsonrpc !=
"2.0") {
76 if (!req.params.is_array()) {
80 if (req.method.empty()) {
84 if (!is_valid_request_id(req.id)) {
89 req.extra.erase(
"jsonrpc");
90 req.extra.erase(
"method");
91 req.extra.erase(
"params");
92 req.extra.erase(
"id");
JSON RPC Exception class.
static constexpr int INVALID_PARAMS
Invalid method parameter(s).
static constexpr int INVALID_REQUEST
The JSON sent is not a valid Request object.
static void from_json(const nlohmann::json &j, jsonrpc_request &r)
Deserializes a JSON object into a jsonrpc_request structure.
Represents a JSON RPC request.