[Haskell-cafe] JSON querying
Simon Marechal
simon at banquise.net
Sun Feb 17 16:25:32 CET 2013
On 02/17/2013 04:01 PM, Sergey Mironov wrote:
> Hi folks. Hackage contains several JSON packages but as far as I see,
> they all provide 'static' conversion from JSON format to Haskell data
> type. Is there a method of converting object containing optional filed
> 'a' to for example Maybe a.
Data.Aeson does this with the .:? operator:
instance FromJSON Bar where
parseJSON (Object v) = Bar <$> v .: "required" <*> v .:? "optional"
More information about the Haskell-Cafe
mailing list