X-Git-Url: http://www.average.org/gitweb/?p=pdns-pipe-nmc.git;a=blobdiff_plain;f=NmcJson.hs;h=14a2f6322d39d913a20a67be222e955b0faad7e5;hp=c92e363ce4b6a6f5d92e10f25806c8e58e45adf3;hb=5f1986b7cb4f20796429433b03205f750a611271;hpb=3677a8d0e1164eb4e7ba481a5e0d025fb1193005 diff --git a/NmcJson.hs b/NmcJson.hs index c92e363..14a2f63 100644 --- a/NmcJson.hs +++ b/NmcJson.hs @@ -7,6 +7,7 @@ module NmcJson ( NmcRes(..) ) where import Data.ByteString.Lazy (ByteString) +import Data.Text as T (unpack) import Data.Map as M (Map, lookup) import Control.Applicative ((<$>), (<*>), empty) import Data.Aeson @@ -65,6 +66,9 @@ data NmcDom = NmcDom { domService :: Maybe [[String]] -- [NmcRRService] } deriving (Show, Eq) instance FromJSON NmcDom where + -- Some just put the IP address in the value, especially in the map. + -- As an ugly hack, try to interpret string as IP (v4) address. + parseJSON (String s) = return emptyNmcDom { domIp = Just [T.unpack s] } parseJSON (Object o) = NmcDom <$> o .:? "service" <*> o .:? "ip"