+import qualified Data.HashMap.Strict as H
+import Data.Aeson.Types
+
+-- Variant of Aeson's `.:?` that interprets a String as a
+-- single-element list, so it is possible to have either
+-- "ip":["1.2.3.4"]
+-- or
+-- "ip":"1.2.3.4"
+-- with the same result.
+(.:/) :: (FromJSON a) => Object -> Text -> Parser (Maybe a)
+obj .:/ key = case H.lookup key obj of
+ Nothing -> pure Nothing
+ Just v -> case v of
+ String s -> parseJSON $ Array (singleton v)
+ _ -> parseJSON v
+