X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=NmcJson.hs;h=651aa46f1be2631fd8245f8ff899544af59546c8;hp=b7449297d3796aca706f78a645b0e49fba28f987;hb=0d59aa176c8ca6665f59426a436671099a393d3f;hpb=6e3dba2c2adb717490fb05b29e2bd50e2e9369a0 diff --git a/NmcJson.hs b/NmcJson.hs index b744929..651aa46 100644 --- a/NmcJson.hs +++ b/NmcJson.hs @@ -2,6 +2,7 @@ module NmcJson ( NmcRes(..) , NmcDom + , emptyNmcDom ) where import Data.ByteString.Lazy (ByteString) @@ -28,7 +29,7 @@ instance FromJSON NmcRRService where <*> o .: "host" parseJSON _ = empty -data NmcRRI2p = NmcRRI2p -- unused +data NmcRRI2p = NmcRRI2p { i2pDestination :: String , i2pName :: String , i2pB32 :: String @@ -84,8 +85,12 @@ instance FromJSON NmcDom where <*> 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 @@ -98,14 +103,3 @@ instance FromJSON NmcRes where <*> o .: "address" <*> o .: "expires_in" parseJSON _ = empty - -main = do - let l = "{\"name\":\"d/dot-bit\",\"value\":\"{\\\"info\\\":{\\\"description\\\":\\\"Dot-BIT Project - Official Website\\\",\\\"registrar\\\":\\\"http://register.dot-bit.org\\\"},\\\"fingerprint\\\":[\\\"30:B0:60:94:32:08:EC:F5:BE:DF:F4:BB:EE:52:90:2C:5D:47:62:46\\\"],\\\"ns\\\":[\\\"ns0.web-sweet-web.net\\\",\\\"ns1.web-sweet-web.net\\\"],\\\"map\\\":{\\\"\\\":{\\\"ns\\\":[\\\"ns0.web-sweet-web.net\\\",\\\"ns1.web-sweet-web.net\\\"]}},\\\"email\\\":\\\"register@dot-bit.org\\\"}\",\"txid\":\"7412603f2e6c3459be56accc6e1f3646b603f3d4a4188119a4072f125c1340d5\",\"address\":\"Mw3KCQcqC44nm75w7r79ZifZbEqT8RetWn\",\"expires_in\":18915}" - let r = decode l :: Maybe NmcRes - case r of - Just resp -> do - let value = (resValue resp) - let dom = decode value :: Maybe NmcDom - print dom - Nothing -> - print "Unparseable NMC response"