Complete rewrite of JSON-RPC

A very different JSON-RPC interface based on type classes.