{-# LANGUAGE OverloadedStrings #-} import Data.Aeson (FromJSON, eitherDecode) import GHC.Generics (Generic) data Bla = Bla { a :: Bool , b :: Bool } | Foo deriving (Show, Generic) instance FromJSON Bla main :: IO () main = do putStrLn $ show (eitherDecode "{\"tag\":\"Bla\",\"contents\":{\"a\":true,\"b\":false}}" :: Either String Bla) putStrLn $ show (eitherDecode "{\"tag\":\"Bla\",\"a\":true,\"b\":false}" :: Either String Bla)