I'm trying to parse the following JSON with aeson.
{
"data": [
{
"id": "34",
"type": "link",
"story": "foo"
},
{
"id": "35",
"type": "link",
"story": "bar"
}
]
}
Since there are a lot of field I'd like to ignore, it seems I should use GHC generics. But how to write a data type definition that uses Haskell keywords like data
and type
? The following of course gives: parse error on input `data'
data Feed = Feed {data :: [Post]}
deriving (Show, Generic)
data Post = Post {
id :: String,
type :: String,
story :: String
}
deriving (Show, Generic)