46{
47 if (!params) {
49 doc->
D(
"example of user defined RPC method that returns more than 3 results");
50 doc->
P(
"arg", MJSON_STRING,
"example string argment");
51 doc->
P(
"optional_arg?", MJSON_INT,
"optional example integer argument");
52 doc->
R(
"string1", MJSON_STRING,
"returns the value of \"arg\" parameter");
53 doc->
R(
"string2", MJSON_STRING,
"returns \"hello\"");
54 doc->
R(
"string3", MJSON_STRING,
"returns \"world!\"");
55 doc->
R(
"value1", MJSON_INT,
"returns the value of \"optional_arg\" parameter");
56 doc->
R(
"value2", MJSON_NUMBER,
"returns 3.14");
57 return doc;
58 }
59
60 MJsonNode* error = NULL;
61
62 std::string arg =
mjsonrpc_get_param(params,
"arg", &error)->GetString();
if (error)
return error;
64
66 printf("user_example2(%s,%d)\n", arg.c_str(), optional_arg);
67
68 MJsonNode* result = MJsonNode::MakeObject();
69
70 result->AddToObject("string1", MJsonNode::MakeString(arg.c_str()));
71 result->AddToObject("string2", MJsonNode::MakeString("hello"));
72 result->AddToObject("string3", MJsonNode::MakeString("world!"));
73 result->AddToObject("value1", MJsonNode::MakeInt(optional_arg));
74 result->AddToObject("value2", MJsonNode::MakeNumber(3.14));
75
77}