You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed to parse field some-string: expected Text, encountered Null #325
I am testing the git.master version and got this error:
Object (fromList [("some-string",Null)])
aeson-example-simple: failed to parse field some-string: expected Text, encountered Null
I would expect that fromJSON would coerce Null to Nothing :: Maybe Text but it sees Null as a Type ( I tested it on both GHC 7.10.2 and 7.10.3 )
Which is a result of the following code:
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
import Data.Aeson
import Data.Text
data Some = Some {someString :: Maybe Text}
deriving Show
instance FromJSON Some where
parseJSON = withObject "Some" $ \o -> do
someString <- o .:? "some-string"
return Some{..}
a :: Value
a = object ([("some-string",Null)])
main = do
print a
case fromJSON $ a of
Error e -> error e
Success some -> print (some :: Some)
Activity
Add missing null handling:
Add missing null handling:
bergmark commentedon Jan 23, 2016
This seems to have been fixed. Currently on master: