Closed
Description
Let's create a type and derive an instance for it.
With TH:
{-# LANGUAGE TemplateHaskell #-}
import Data.Aeson
import Data.Aeson.TH
data X = X {a :: (Int, Int, Int)}
deriving Show
deriveJSON defaultOptions ''X
Or with generics:
{-# LANGUAGE DeriveGeneric #-}
import Data.Aeson
data X = X {a :: (Int, Int, Int)}
deriving (Show, Generic)
instance FromJSON X where
parseJSON = genericParseJSON defaultOptions
Then try to decode an invalid value:
> eitherDecode "{\"a\": [1, 2, true]}" :: Either String X
Left "Error in $[2]: expected Int, encountered Boolean"
I believe it should be $.a[2]
.
(I checked with latest Aeson from the repository, commit 2f0b989.)