aeson-filthy 0.1.3 → 0.1.4
raw patch · 3 files changed
+27/−3 lines, 3 filessetup-changedPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Aeson.Filthy: EmptyObject :: () -> EmptyObject
+ Data.Aeson.Filthy: [emptyObject] :: EmptyObject -> ()
+ Data.Aeson.Filthy: instance Data.Aeson.Types.FromJSON.FromJSON Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance Data.Aeson.Types.ToJSON.ToJSON Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance GHC.Classes.Eq Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance GHC.Classes.Ord Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance GHC.Enum.Bounded Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance GHC.Enum.Enum Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance GHC.Generics.Generic Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance GHC.Read.Read Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: instance GHC.Show.Show Data.Aeson.Filthy.EmptyObject
+ Data.Aeson.Filthy: newtype EmptyObject
Files
- Setup.hs +0/−2
- aeson-filthy.cabal +1/−1
- src/Data/Aeson/Filthy.hs +26/−0
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
aeson-filthy.cabal view
@@ -1,5 +1,5 @@ name: aeson-filthy-version: 0.1.3+version: 0.1.4 homepage: https://github.com/deviant-logic/aeson-filthy bug-reports: https://github.com/deviant-logic/aeson-filthy/issues license: BSD3
src/Data/Aeson/Filthy.hs view
@@ -24,6 +24,10 @@ , EmptyAsNothing(..) + -- * EmptyObject++ , EmptyObject(..)+ -- * Time , RFC2822Time(..) @@ -182,6 +186,28 @@ instance FromJSON a => FromJSON (EmptyAsNothing a) where parseJSON "" = pure $ EmptyAsNothing Nothing parseJSON x = EmptyAsNothing <$> parseJSON x++-- | Sometimes an empty object is all there is (/e.g./ returned instead of HTTP 204).+--+-- >>> decode "{}" :: Maybe EmptyObject+-- Just (EmptyObject {emptyObject = ()})+--+-- >> eitherDecode "{\"\":\"\"}" :: Either String EmptyObject+-- Left "Error in $: parsing EmptyObject failed, encountered non-empty Object"+--+-- >>> encode (EmptyObject ())+-- "{}"+newtype EmptyObject = EmptyObject { emptyObject :: () }+ deriving (Eq, Ord, Enum, Bounded, Read, Show, Generic)++instance FromJSON EmptyObject where+ parseJSON = withObject "EmptyObject" $ \o ->+ if HM.null o+ then return $ EmptyObject ()+ else fail "parsing EmptyObject failed, encountered non-empty Object"++instance ToJSON EmptyObject where+ toJSON (EmptyObject ()) = object [] -- | A RFC 2822 encoded time value, allowing the modern RFC 2822 format. -- These parsers do not currently handle the more messy whitespace and comments