I have a json like:
{
"name" : "Sam",
"items": [ "sword", "shield", [] ]
}
and a data type
data Adventurer = Adventurer {
name :: String,
items :: [String]
} deriving (Generic, Show, FromJSON, ToJSON)
The problem is caused by the fact that the "items" field has the extra [] in the array and I get "expected String, encountered Array".
I've been trying to fix this with custom data types for the elements of the "items" array, or trying make a custom parser to ignore the extra array.
Is there a way to parse an array and only take the items which are of a certain type, dropping the rest?