Closed
Description
I seem to be unable to successfully use methods whose arguments are types such as enum class
es, where I have used nlohmann::json
to provide serialisation and deserialisation routines. The method successfully binds, but when I invoke it using curl
, there is an error response of invalid parameter: must be object, but is string for parameter \"e\"
The attached zip file contains a repro case. The enum itself is:
enum class MyEnum { Zero, One, Two };
with serialisation provided by NLOHMANN_JSON_SERIALIZE_ENUM
. There are then two methods which I'm attempting to call:
int MyService::OptionOne( MyEnum e ) {
std::cout << __FUNCTION__ << std::endl;
return static_cast<int>(e);
}
int MyService::OptionTwo( std::string s ) {
std::cout << __FUNCTION__ << std::endl;
nlohmann::json j(s);
MyEnum e = j.get<MyEnum>();
return static_cast<int>(e);
}
I can invoke the second via:
curl http://localhost:8483/jsonrpc -H "Content-Type application/json" --data '{ "method":"OptionTwo", "params":{"s":"One"}, "id":10, "jsonrpc": "2.0" }'
However, when I try to call the first:
curl http://localhost:8483/jsonrpc -H "Content-Type application/json" --data '{ "method":"OptionOne", "params":{"e":"One"}, "id":10, "jsonrpc": "2.0" }'
I see the error noted above.
Metadata
Metadata
Assignees
Labels
No labels