Decoding object with multiple constuctors with separated tags
问题 I have data in form of pairs of two strings, where first is the key identifying shape of the JSON delivered as the second one. fooooo {"a": 123} barrrr {"a": 123, "b": 123} fooooo {"a": 123} I would like to parse it to same data type, based on the fopooo , baasdasda1 , etc : data Test = Foo { a :: Int , b :: Int } | Bar { a :: Int } deriving (Show, Generic) In the Aeson there is a tag feature, but it seems to require presence of the tag inside the object. Is there some way to handle it like