Skip to content

Instantly share code, notes, and snippets.

@weskerfoot
Created March 8, 2021 18:23
Show Gist options
  • Save weskerfoot/68eff70507c851f62263d27da0979f60 to your computer and use it in GitHub Desktop.
Save weskerfoot/68eff70507c851f62263d27da0979f60 to your computer and use it in GitHub Desktop.
{-# LANGUAGE OverloadedStrings #-}
import Data.Aeson
data Name = Name {
firstName :: String,
lastName :: String
} deriving (Show, Eq)
instance FromJSON Name where
parseJSON = withObject "Name" $ \v -> Name
<$> v .: "firstName"
<*> v .: "lastName"
main = print (decode "{\"firstName\": \"Rachel\", \"lastName\": true}" :: Maybe Name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment