Im struggling to parse the below JSON using the Aeson library.
Im only interested in getting file1 but I cant seem to manage it.
Does anyone have suggestions?
The JSON
{"files":[["file1.wav",["file2.jpg","file3.jpg"]]]}
My code
data File = File Text deriving (Show, Generic, ToJSON)
instance FromJSON File where
parseJSON jsn = do
arrays <- parseJSON jsn
let x = arrays !! 0 !! 0
return $ File x
Error message
"Error in $.files[0][1]: parsing Text failed, expected String, but encountered Array"