]> www.average.org Git - pdns-pipe-nmc.git/blobdiff - Data/JsonRpcClient.hs
wip handling response
[pdns-pipe-nmc.git] / Data / JsonRpcClient.hs
index 573e94df14529337d3d04b4cf44eb9a508a85978..6038695359b83a0131d96bf0219a13a976e043ce 100644 (file)
@@ -46,9 +46,9 @@ data JsonRpcError = JsonRpcError { jrpcErrCode    :: Int
                                  } deriving (Show)
 instance FromJSON JsonRpcError where
   parseJSON (Object o) = JsonRpcError
-                                <$> o .: "code"
-                                <*> o .: "error"
-                                <*> o .: "data"
+                                <$> o .:  "code"
+                                <*> o .:  "message"
+                                <*> o .:? "data"
   parseJSON x = return $ JsonRpcError
                                 (-32600)
                                 "Unparseable error object"
@@ -60,9 +60,9 @@ data JsonRpcResponse = JsonRpcResponse { jrpcRspResult :: Maybe Value
                                        } deriving (Show)
 instance FromJSON JsonRpcResponse where
   parseJSON (Object o) = JsonRpcResponse
-                                <$> o .: "result"
-                                <*> o .: "error"
-                                <*> o .: "id"
+                                <$> o .:? "result"
+                                <*> o .:  "error"
+                                <*> o .:  "id"
   parseJSON x = return $ JsonRpcResponse
                                 Nothing
                                 (JsonRpcError