module NmcJson ( NmcRes(..)
, NmcDom
+ , emptyNmcDom
) where
import Data.ByteString.Lazy (ByteString)
<*> o .: "host"
parseJSON _ = empty
-data NmcRRI2p = NmcRRI2p -- unused
+data NmcRRI2p = NmcRRI2p
{ i2pDestination :: String
, i2pName :: String
, i2pB32 :: String
<*> o .:? "ds"
parseJSON _ = empty
+emptyNmcDom = NmcDom Nothing Nothing Nothing Nothing Nothing Nothing
+ Nothing Nothing Nothing Nothing Nothing Nothing
+ Nothing Nothing Nothing Nothing Nothing Nothing
+
data NmcRes = NmcRes { resName :: String
- , resValue :: ByteString -- NmcDom
+ , resValue :: ByteString -- string with NmcDom
, resTxid :: String
, resAddress :: String
, resExpires_in :: Int
case parseJsonRpc (responseBody rsp) :: Either JsonRpcError NmcRes of
Left jerr -> Left $ "Unparseable response: " ++ (show (responseBody rsp))
Right jrsp ->
- case decode (resValue jrsp) :: Maybe NmcDom of
- Nothing -> Left $ "Unparseable value: " ++ (show (resValue jrsp))
- Just dom -> Right dom
+ case resValue jrsp of
+ "" -> Right emptyNmcDom
+ vstr ->
+ case decode vstr :: Maybe NmcDom of
+ Nothing -> Left $ "Unparseable value: " ++ (show vstr)
+ Just dom -> Right dom
-- NMC interface