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