Move JSONRPC_API from individual methods to class for several classes

This is needed at least by g++ for virtual classes and exceptions with
default visibility set to hidden. Not clear if the same is true on
Windows, but shouldn't hurt anything.