Copyright | (c) Anton Gushcha 2016 |
---|---|
License | MIT |
Maintainer | ncrashed@gmail.com |
Stability | experimental |
Portability | Portable |
Safe Haskell | None |
Language | Haskell2010 |
Common usage:
data PagedList i a = PagedList { pagedListItems :: ![a] -- ^ Payload , pagedListPages :: !Word -- ^ Count of available pages } deriving (Generic, Show) $(deriveJSON (derivePrefix "pagedList") ''PagedList)
It will work with the following jsons:
{ "items": [], "pages": 0 }
Synopsis
- derivePrefix :: Text -> Options
- deriveJSON :: Options -> Name -> Q [Dec]
Documentation
derivePrefix :: Text -> Options Source #
For aeson deriving, drop prefix t and map to lower
:: Options | Encoding options. |
-> Name | Name of the type for which to generate |
-> Q [Dec] |
Generates both JSONFun
and FromJSON
instance declarations for the given
data type or data family instance constructor.
This is a convienience function which is equivalent to calling both
deriveToJSON
and deriveFromJSON
.