+data JsonRpcRequest = JsonRpcRequest { jrpcVersion :: JsonRpcVersion
+ , jrpcReqMethod :: ByteString
+ , jrpcReqParams :: [ByteString]
+ , jrpcReqId :: ByteString
+ } deriving (Show)
+instance ToJSON JsonRpcRequest where
+ toJSON (JsonRpcRequest version method params id) =
+ let l = [ "method" .= method , "params" .= params , "id" .= id ]
+ in case version of
+ JsonRpcV1 -> object l
+ JsonRpcV2 -> object $ ("jsonrpc" .= toJSON ("2.0" :: ByteString)):l
+