Created
October 23, 2018 09:49
-
-
Save cemerick/d2f3c279df9cc3ceb827fb64354dcc0a 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
data Val = Val { foobar :: Int } deriving (Generic, Show) | |
instance JSON.FromJSON Val where | |
parseJSON = JSON.genericParseJSON | |
$ JSON.defaultOptions { JSON.fieldLabelModifier = filter (/= '-') } | |
{- | |
$ eitherDecode "{\"foo-bar\": 1}" :: Either String Val | |
Left "Error in $: key \"foobar\" not present" | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment