Update json_rpc example to work on both versions of Boost.JSON

This commit is contained in:
Peter Dimov
2023-09-26 00:53:40 +03:00
parent 3047e5a72f
commit c89e4dd3db

View File

@@ -34,7 +34,7 @@ template<class C1, class C2, class R, class... A>
template<class C>
boost::json::value
call( C & c, boost::string_view method, boost::json::value const & args )
call( C & c, boost::string_view method, boost::json::array const & args )
{
using Fd = boost::describe::describe_members<C,
boost::describe::mod_public | boost::describe::mod_function>;
@@ -46,7 +46,7 @@ template<class C>
if( !found && method == D.name)
{
result = call_impl( c, D.pointer, args.as_array() );
result = call_impl( c, D.pointer, args );
found = true;
}
@@ -80,6 +80,6 @@ BOOST_DESCRIBE_STRUCT(Object, (), (greet, add))
int main()
{
Object obj;
std::cout << call( obj, "greet", {{ "world" }} ) << std::endl;
std::cout << call( obj, "add", {{ 1, 2 }} ) << std::endl;
std::cout << call( obj, "greet", { "world" } ) << std::endl;
std::cout << call( obj, "add", { 1, 2 } ) << std::endl;
}