I am trying to convert a JSON String into an ADT
This is my ADT:
data UserList = UserList
{ userListUsers :: [UserId] }
This is my FromJSON
instance for UserList
:
instance FromJSON UserList where
parseJSON (Object o) = UserList
<$> ((o .: "relationships") >>= (.: "users") >>= (mapM (.: "id")))
And finally this is my JSON String:
{
"relationships": {
"users": [
{ "type": "User","id": "8" }
]
}
}
My Yesod server is giving 400 Bad Request
, without any further help, I think I may not be converting the users
array correctly