@@ -108,8 +108,8 @@ data Request = Request Text Args (Maybe Id)
108
108
instance FromJSON Request where
109
109
parseJSON (Object x) = (checkVersion =<< x .:? versionKey .!= jsonRpcVersion) *>
110
110
(Request <$>
111
- x .: methodKey <*>
112
- (parseParams =<< x .:? paramsKey .!= emptyObject) <*>
111
+ x .: " method " <*>
112
+ (parseParams =<< x .:? " params " .!= emptyObject) <*>
113
113
(Just <$> x .: idKey <|> return Nothing )) -- (.:?) parses Null value as Nothing
114
114
where parseParams (Object obj) = return $ Left obj
115
115
parseParams (Array ar) = return $ Right ar
@@ -122,7 +122,7 @@ data Response = Response Id (Either RpcError Value)
122
122
instance ToJSON Response where
123
123
toJSON (Response i result) = object pairs
124
124
where pairs = [ versionKey .= jsonRpcVersion
125
- , either (errorKey .= ) (resultKey .= ) result
125
+ , either (" error " .= ) (" result " .= ) result
126
126
, idKey .= i]
127
127
128
128
data Id = IdString Text | IdNumber Number | IdNull
@@ -149,9 +149,9 @@ instance Error RpcError where
149
149
150
150
instance ToJSON RpcError where
151
151
toJSON (RpcError code msg data') = object pairs
152
- where pairs = catMaybes [ Just $ codeKey .= code
153
- , Just $ msgKey .= msg
154
- , (dataKey .= ) <$> data' ]
152
+ where pairs = catMaybes [ Just $ " code " .= code
153
+ , Just $ " message " .= msg
154
+ , (" data " .= ) <$> data' ]
155
155
156
156
-- | Creates an 'RpcError' with the given error code and message.
157
157
-- According to the specification, server error codes should be
@@ -169,16 +169,3 @@ jsonRpcVersion, versionKey, idKey :: Text
169
169
jsonRpcVersion = " 2.0"
170
170
versionKey = " jsonrpc"
171
171
idKey = " id"
172
-
173
- methodKey , paramsKey :: Text
174
- methodKey = " method"
175
- paramsKey = " params"
176
-
177
- resultKey , errorKey :: Text
178
- resultKey = " result"
179
- errorKey = " error"
180
-
181
- codeKey , msgKey , dataKey :: Text
182
- codeKey = " code"
183
- msgKey = " message"
184
- dataKey = " data"
0 commit comments