I am writing an app that use the Github Webhooks API. In the hook message i got this JSON structure: http://organicorange.ro:8000/set
I am doing the type declaration like this:
newtype CommitList = CommitList {commitList :: [Commit]}
instance FromJSON CommitList where
parseJSON (Object o) = CommitList <$> o .: "commits"
parseJSON _ = mzero
data Commit = Commit {ids :: String, message :: String, url :: String, modified :: [String], author :: Auth} deriving (Show)
instance FromJSON Commit where
parseJSON (Object o) = Commit <$> o .: "id" <*> o .: "message" <*> o .: "url" <*> o .: "modified" <*> o .: "author"
parseJSON _ = mzero
data Auth = Auth {name :: String, email :: String, username :: String} deriving (Show)
instance FromJSON Auth where
parseJSON (Object o) = Auth <$> o .: "name" <*> o .: "email" <*> o .: "username"
parseJSON _ = mzero
How can I parse the "modified" array to return a list?