From 5f1986b7cb4f20796429433b03205f750a611271 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Thu, 3 Apr 2014 18:03:09 +0400 Subject: [PATCH] hack to handle ip-only value for the domain --- NmcJson.hs | 4 ++++ 1 file changed, 4 insertions(+) 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" -- 2.39.2