Created
March 8, 2021 18:23
-
-
Save weskerfoot/68eff70507c851f62263d27da0979f60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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